1
$\begingroup$

Doing some Log plots and seeing odd interactions with Show and PlotRange

Simple example

ListLogPlot[{Range[100], Range[100]^2}\[Transpose]];
Show[%, PlotRange -> {1, 5}];
Grid[{{%%, %}}]

I would have expected the plot range on the righthand plot to be (1,5) not (Exp(1), Exp(5))

Is this expected? If so it seems wrong to me. enter image description here

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Yes, it is somehow expected. The result of ListLogPlot is a Graphics:

data = Transpose[{Range[100], Range[100]^2}]
(* {{1, 1}, {2, 4}, {3, 9}, {4, 16}, ...} *)

plot = ListLogPlot[data, PlotRange -> {{1, 100}, {1, 10}}];

plot // InputForm
(* Graphics[..., 
     Point[{{1., 0.}, {2., 1.3862943611198906}, 
            {3., 2.1972245773362196}, {4., 2.772588722239781}, 
            {5., 3.2188758248682006}, {6., 3.58351893845611} ...},
     PlotRange -> {{1., 100.}, {0., 2.302585092994046}}, ...] *)

Graphics uses the regular cartesian coordinates, and it was a ListLogPlot's job to convert your data points and PlotRange to the log scale, which you can see by observing the coordinates inside Point and the resulting PlotRange.

Therefore, when you alter the PlotRange within Show, you are not working in the original coordinate system of your data anymore, but in this transformed one.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.