5
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$ Mar 15, 2013 at 2:41
  • $\begingroup$ @JonathanShock fixed, and I moved the definition for omega above k as it depends on it, also. $\endgroup$
    – rcollyer
    Mar 15, 2013 at 2:48
  • $\begingroup$ 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? $\endgroup$ Mar 15, 2013 at 2:50
  • $\begingroup$ @JonathanShock about to put up an answer, and adding the pictures won't illustrate the problem. $\endgroup$
    – rcollyer
    Mar 15, 2013 at 2:50
  • $\begingroup$ @JonathanShock it's up, if you want to see the explanation. $\endgroup$
    – rcollyer
    Mar 15, 2013 at 2:57

1 Answer 1

8
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Very nice, thanks a lot for this helpfull answer !!!! $\endgroup$
    – federico
    Mar 17, 2013 at 19:03

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.