# Showing ListLogPlot and redrawing FrameTicks

I want to combine two ListLogPlot plots. For example

p1 = ListLogPlot[Range@100, Frame -> True]
p2 = ListLogPlot[10^4*Range@100, Frame -> True]


I got

Show[p1, p2, PlotRange -> All]


By using the ticks of p2, I got

Show[p1, p2, PlotRange -> All, FrameTicks -> (FrameTicks /. p2[[2]])]


Both of the results have ticks which only cover a part of the figure.

By trying

Show[p1, p2, PlotRange -> All, FrameTicks -> Automatic]


I actually got a wrong result with completely wrong ticks.

So would there be a way to let Show combine the plots and redraw the ticks automatically? Thanks!

Some notes:

(1) There is a similar post:

Scale label problem of multiple ListLogPlot graphs

However, it doesn't solve my problem because the two plots here have different scales which are non-overlapping. Thus the problem is not solved simply by ordering the plots or choosing which ticks to use.

(2) I could instead do ListLogPlot[{Range@100, 10^4*Range@100}]. However, actually each plot command in my realistic case is complicated enough thus it would be easier and more modular for me to draw them separately and combine them afterwards.

• This is quite odd. As a quick fix, you can specify an unusually large plot range in the first plot you feed into Show and fake the frame ticks. So, use p1 = ListLogPlot[Range@100, Frame -> True, PlotRange -> {All, {1, 10^6}}] and the rest of your code the same. – gpap Apr 11 '14 at 15:27
• @gpap : Thanks a lot for the comment! Yes, this is a very good idea. Nevertheless I would expect more convenient ways because I actually have many figures to plot and it's hard for me to predict the range before I get the figure. It would be quite boring (though possible) to tune them one by one... – Yi Wang Apr 11 '14 at 15:30
• Yes, I understand the issue with not knowing the plot range in advance but the point of this is that you won't have to tune them one by one, all you need to tune is the first one. To see what I mean, create another plot p3 in the 10^12 range. Now if you add , PlotRange -> {All, {1, 10^14}} to p1 and use Show[{p1,p2,p3}, PlotRange -> All] it should look OK. – gpap Apr 11 '14 at 15:40
• (but I agree, there is something going wrong here and this shouldn't be the standard way to fix it) – gpap Apr 11 '14 at 15:41
• Thanks @gpap. Sorry I was not clear. My point is I need to do a lot of Show[p1, p2]; Show[p3, p4]; ... and I mean I have to tune for each pair :) – Yi Wang Apr 11 '14 at 16:29

I really don't understand why Show behaves this way with LogPlots. Anyway a way out is to manually extract the the ticks from the plots:

    logShow[a__Graphics, opts : OptionsPattern[Show]] :=
With[{ft = (FrameTicks /. #[[2]])[[1, 1]] & /@ {a}},
Show[{a}, FrameTicks -> {All, Join @@ ft}, Evaluate[opts]]
]


and although this is probably easy to break (I don't know how to write a pattern that tells it that a is a sequence of logplots for instance) it should work.

p1 = ListLogPlot[Range@100, Frame -> True];
p2 = ListLogPlot[10^4*Range@100, Frame -> True];
p3 = ListLogPlot[10^9*Range@100, Frame -> True];


Indeed:

logShow[p1, p2, PlotRange->All]


and

logShow[p1, p2, p3, PlotRange -> All]


the obvious problem being that it doesn't fill the intermediate ticks between the plots. So better than nothing but not quite as Show` is expected to work.

• Thanks a lot for the help! It is not really a perfect solution but considering the automatic way provided by Mathematica is buggy, this may be so far the best that we can do (without tons of coding). So let me accept this answer :) – Yi Wang Apr 14 '14 at 10:27