Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using Show with PlotRange -> All to overplot multiple ListLogLogPlot. The resulting plot has axis ticks that are unevenly clustered toward the top of the y-axis. (right image)

When I use Show with PlotRange -> All to overplot the same data using ListPlot, the resulting plot has evenly spaced ticks along the y-axis (left image).

enter image description here

How can I use Show with PlotRange -> All to overplot ListLogLogPlot and get even axis ticks along the y-axis? I can force a fix by specifying the entire range with PlotRange in the first plot, but in general I will not know ahead of time the plot ranges and would like to avoid editing the plots themselves.

share|improve this question
1  
Could you post the code for a small working example? –  belisarius Jan 6 '13 at 22:02
1  
Because for example this y[x_, p_] := Log[x]/p - p/2; a[p_] := Table[{x, y[x, p]}, {x, 10^3, 10^4, 10}]; ListLogLogPlot[{a[3.7], a[3], a[2]}, PlotRange -> All] plots without problem. –  belisarius Jan 6 '13 at 22:18
    
This problem arises because the Ticks specification from the first plot--obviously the red one in this case--covers only a narrow range and carries through to the output. Ideally, one should re-generate the ticks over the complete range of the combined plot. –  Oleksandr R. Jan 8 '13 at 10:16
add comment

1 Answer

Show takes the options from the first graphics object in its input. This means that when you have two graphs, one with Ticks specified and one without and you put the one with Ticks first, this will dictate the Ticks in the overall output. If you put them second then the Ticks->Automatic option from the first graph will be used. You can however override this by specifying Ticks->Automatic in the Show command itself. Let's say we have two plots defined by:

p1 = Plot[x, {x, 0, 3 \[Pi]}, Ticks -> {{0, Pi, 2 Pi, 3 Pi}, {-1, 1}}];
p2 = Plot[x^2, {x, 0, 6 \[Pi]}];

We can get three very different results, depending on the ordering in Show and the options we give Show:

pa = Show[p1, p2];
pb = Show[p2, p1];
pc = Show[p1, p2, Ticks -> Automatic];

three different versions

In the first plot the first element of Show has Ticks specified and thus this is the option used. You can also see that the PlotRange is taken from the first plot.

In the second plot, the first element is p2 and this has the Ticks option as the default value. This is then used for the overall graphics object.

In the third plot, while the first element is p1, we can override the option by specifying Ticks in the Show command. Note however that the PlotRange is still that from the first plot and not from the second.

All of this and more can be found in the details part of the documentation for Show.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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