I am wondering why there is a difference in the results from evaluating the two expressions, which differ only in the order of the arguments given to Show.
When I run
Animate[Show[spring[t], bob[t], traj], {t, 0, 20}]
the animation is different from
Animate[Show[traj, spring[t], bob[t]], {t, 0, 20}]
Parts of the plot get cut off, depending on the order of the arguments.
Answer
The order of arguments in Show makes a difference in two ways:
The
Graphicsexpression produced byShowwill inherit options from the first argumentThe first argument will appear in the bottom layer, the last one in the top layer.
The most common problem (1) causes is that the plot range is inherited from the first argument, causing parts of the second one to be cut off. For example:
plot1 = Plot[x^2/20, {x, 0, 5}]
plot2 = Plot[Sin[x], {x, 0, 5}]
Show[plot1, plot2]
Show[plot2, plot1]

The simplest solution is to set the option explicitly in Show:
Show[plot1, plot2, PlotRange -> All]

Comments
Post a Comment