# LogPlot with a Rectangle [closed]

If I combine a Plot with a Rectangle (as following) I obtain the expected result:

fig = Plot[10^-x, {x, 1, 5}];
rec = Graphics[{LightGray, Rectangle[{2, 10^-2}, {3, 10^-4}]}];
Show[rec, fig, Frame -> True, AspectRatio -> .5] However, If I use LogPlot I obtain the following:

fig = LogPlot[10^-x, {x, 1, 5}]
rec = Graphics[{LightGray, Rectangle[{2, -2}, {3, -4}]}];
Show[rec, fig, Frame -> True, AspectRatio -> .5] That is, the rectangle is at the correct position but the curve has been shifted. Indeed, fig is now: Is it a bug or am I doing something wrong?

• Seems a simple enough mistake - you took the base-10 log of your rectangle coordinates, but LogPlot uses the natural log. – Jason B. Aug 3 '18 at 21:04
• @Jason B. thanks! You are indeed right! Could you please convert this comment into an answer? – Valerio Aug 4 '18 at 10:36

From the documentation for Show:

Show uses the options from the first graphic If you change the order you will get the scaling options of the LogPlot instead, including the interpretation of the coordinates

fig = LogPlot[10^-x, {x, 1, 5}];
rec = Graphics[{LightGray, Rectangle[{2, -2}, {3, -4}]}];
Show[fig, rec, Frame -> True, AspectRatio -> .5] Solution

LogPlot[10^-x
, {x, 1, 5}
, Prolog -> {LightGray, Rectangle[{2, Log[10^-2]}, {3, Log[10^-3]}]}
, PlotTheme -> "Scientific"
, AspectRatio -> 1/2
, PlotRange -> {10^-6, 1}
] • I see, but how do I obtain the correct plot? – Valerio Aug 3 '18 at 20:47
• @Valerio I have updated my answer. – rhermans Aug 3 '18 at 21:02
• thanks but I prefer the solution by Jason B. as it uses the original structure; I need indeed to put many objects together. – Valerio Aug 4 '18 at 10:37

We can produce your first image with

Plot[10^-x, {x, 1, 5}, Frame -> True,
Prolog -> {LightGray, Rectangle[{2, 10^-2}, {3, 10^-3}]}]


I would therefore expect the following to work, and it does.

LogPlot[10^-x, {x, 1, 5}, Frame -> True,
Prolog -> {LightGray, Rectangle[{2, Log[10^-2]}, {3, Log[10^-3]}]}]


Note that I changed a 4 to a 3; change it back if that's not what you meant.