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 try to combine three list plots with the Show command. Here is the first one:

asteroidCount = 
  BinCounts[
   Sort@Cases[(AstronomicalData[#, "SemimajorAxis"]/149597870691) & /@
       Join[AstronomicalData["InnerMainBeltAsteroid"], 
       AstronomicalData["MainBeltAsteroid"], 
       AstronomicalData["OuterMainBeltAsteroid"]], x_?NumberQ], {2, 
    3.5, .005}];
m = ListPlot[asteroidCount, Joined -> True, Filling -> 0, Mesh -> All,
   Ticks -> {Table[{Rescale[x, {2, 3.5}, {0, 301}], x}, {x, 2, 
      3.5, .2}], Automatic}]

The second one:

omega[a_] := 2 Pi/a^(3/2);
k = ListPlot[
  Flatten[Table[{a /. FindRoot[omega[a]/omega[5.2] == j/i, {a, 1}], 
     700}, {j, 5, 6, 1}, {i, 1, 5, 1}], 1], Filling -> Axis, 
  PlotRange -> {{0, 15}, {0, 800}}, PlotMarkers -> Automatic, 
  PlotStyle -> Black, Filling -> Axis, FillingStyle -> {Red},
  Epilog -> {AbsolutePointSize[8], Black, 
    Text["\!\(\*SubscriptBox[\(M\), \(J\)]\)", {5.2, 1}], 
    Point[{5.2, 0.1}]
    }]

And finally the third one:

l = ListPlot[
  Flatten[Table[{a /. FindRoot[omega[a]/omega[5.2] == j/i, {a, 1}], 
     700}, {j, 1, 5, 1}, {i, 5, 6, 1}], 1], Filling -> Axis, 
  PlotRange -> {{0, 15}, {0, 800}}, PlotMarkers -> Automatic, 
  PlotStyle -> Black, Filling -> Axis, FillingStyle -> {Red},
  Epilog -> {AbsolutePointSize[8], Black, 
    Text["\!\(\*SubscriptBox[\(M\), \(J\)]\)", {5.2, 1}], 
    Point[{5.2, 0.1}]
    }]

When I use Show[k,l,m] I see only the last two plots (l and m) and I don't know why... Can someone help me please?

share|improve this question
    
steroidCount in the first line should be asteroidCount. I attempted to edit but it said that an edit had to be at least six characters. –  Jonathan Shock Mar 15 '13 at 2:41
    
@JonathanShock fixed, and I moved the definition for omega above k as it depends on it, also. –  rcollyer Mar 15 '13 at 2:48
    
It also seems that you are loading the astronomical data on the order of 50000 times to get the initial asteroiodcount. Can you show us the individual plots to see what the problem might be in Show? –  Jonathan Shock Mar 15 '13 at 2:50
    
@JonathanShock about to put up an answer, and adding the pictures won't illustrate the problem. –  rcollyer Mar 15 '13 at 2:50
    
@JonathanShock it's up, if you want to see the explanation. –  rcollyer Mar 15 '13 at 2:57

1 Answer 1

up vote 7 down vote accepted

Simply, they are not on the same scale. Modifying the Ticks of m gives the illusion that they are, but that is for display, only, and does not reflect the true x-axis found in m. If you extract the display options, like this

m /. Graphics[___, opt : OptionsPattern[]] :> Flatten@{opt}

you get

PlotRange -> {{0, 300.}, {0, 540.}}

among others. So, the x-axis actually goes from 0 to 300 because the data only consists of y-values. To truly change the range of the x-axis, you need to use DataRange, as follows

m = ListPlot[asteroidCount, Joined -> True, Filling -> 0, Mesh -> All,
   DataRange -> {2, 3.5}]

enter image description here

The ranges of the combined pictures are still not completely compatible, but they can be fully displayed using

Show[{m, k, l}, PlotRange -> All]

enter image description here

share|improve this answer
    
Very nice, thanks a lot for this helpfull answer !!!! –  federico Mar 17 '13 at 19:03

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.