2
$\begingroup$

Consider the following code:

data1 = {{0.70, 0.05}, {0.71, 0.06}, {0.72, 0.07}};
data2 = {{0.72, 0.07}, {0.72, 0.08}, {0.72, 0.1}, {0.72, 0.2}, {0.72,0.4}, {0.73, 0.6},{0.73, 0.8}, {0.73, 1.0}, {0.73, 2.0}, {0.74, 4.0}, {0.74, 5.0}, {0.74, 6.0}, {0.75, 8.0},{0.78, 10.0}};
data3 = {{0.72, 0.07}, {0.74, 0.08}, {0.76, 0.1}, {0.84, 0.2}, {0.9, 0.4}, {0.96, 0.6}, {1.0, 0.8}, {1.02, 1.0}, {1.12, 2.0}, {1.22, 4.0}, {1.26, 5.0}};

sg = ListLogPlot[Tooltip[data1], Joined -> True, Mesh -> Automatic];
sl = ListLogPlot[Tooltip[data2], Joined -> True, Mesh -> Automatic];
lg = ListLogPlot[Tooltip[data3], Joined -> True, Mesh -> Automatic];
Show[sg, sl, lg, PlotRange -> All]

There is no problem with the individual plots but their scales mess up when I combine them using Show command.The scale label just simply disappear. Any idea on how to fix this?

$\endgroup$
1
  • $\begingroup$ Try: Show[sl, sg, lg, PlotRange -> All]. $\endgroup$
    – kglr
    Dec 27, 2012 at 8:15

1 Answer 1

2
$\begingroup$

From Docs>>Show>>Possible Issues

Show uses the options from the first graphic

In this case, the Ticks and/or FrameTicks options from the first graphic are used unless Show is provided explicit settings for this option. Since the PlotRange and FrameTicks settings for sg cover only a portion of the whole range for sl and lg, you see only the ticks/labels from sg when you use

  Show[sg, sl, lg, PlotRange -> All]

First, few changes in the code to distinguish the three plots when they are `Show'n together:

sg = ListLogPlot[Tooltip[data1], Joined -> True, Mesh -> Automatic, 
  PlotStyle -> Directive[Opacity[.5], Thin, Red]];
sl = ListLogPlot[Tooltip[data2], Joined -> True, Mesh -> Automatic, 
  PlotStyle -> Directive[Opacity[.5], Thickness[.01], Blue]];
lg = ListLogPlot[Tooltip[data3], Joined -> True, Mesh -> Automatic, 
  PlotStyle -> Directive[Opacity[.5], Thickness[.02], Green]];

Since the PlotRange and FrameTicks settings for sl are "more representative" (so to speak), changing the order of graphics in Show

Show[sl, sg, lg, PlotRange -> All, Frame -> True, AspectRatio -> 1]

gives

enter image description here

Alternatively, you could have the input graphics in any order but provide the settings for FrameTicks explicitly in Show to get the same result:

 Show[sg, sl, lg, PlotRange -> All, Frame -> True, AspectRatio -> 1, 
  FrameTicks -> (FrameTicks /. sl[[2]])] 

where I used the facts that

  1. You can get the options (not all of them, btw) of a graphics object by looking into its second Part, that is sl[[2]] contains the option settings PlotRange, AxesLabel, FrameTicks ... etc for sl.
  2. Using the replacement rule FrameTicks /. sl[[2]] we get the values of this option in sl.
$\endgroup$

Your Answer

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

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