1.9.3 Redrawing and Combining Plots
Mathematica saves information about every plot you produce, so that you can later redraw it. When you redraw plots, you can change some of the options you use.
Functions for manipulating plots.
Here is a simple plot. Graphics is usually printed on the output line to stand for the information that Mathematica saves about the plot.
In[1]:= Plot[ChebyshevT[7, x], {x, 1, 1}]
Out[1]=
This redraws the plot from the previous line.
In[2]:= Show[%]
Out[2]=
When you redraw the plot, you can change some of the options. This changes the choice of scale.
In[3]:= Show[%, PlotRange > {1, 2}]
Out[3]=
This takes the plot from the previous line, and changes another option in it.
In[4]:= Show[%, PlotLabel > "A Chebyshev Polynomial"]
Out[4]=
By using Show with a sequence of different options, you can look at the same plot in many different ways. You may want to do this, for example, if you are trying to find the best possible setting of options.
You can also use Show to combine plots. It does not matter whether the plots have the same scales: Mathematica will always choose new scales to include the points you want.
This sets gj0 to be a plot of from to .
In[5]:= gj0 = Plot[BesselJ[0, x], {x, 0, 10}]
Out[5]=
Here is a plot of from to .
In[6]:= gy1 = Plot[BesselY[1, x], {x, 1, 10}]
Out[6]=
This shows the previous two plots combined into one. Notice that the scale is adjusted appropriately.
In[7]:= gjy = Show[gj0, gy1]
Out[7]=
Using Show[, , ... ] you can combine several plots into one. GraphicsArray allows you to draw several plots in an array.
Drawing arrays of plots.
This shows the plots given above in an array.
In[8]:= Show[GraphicsArray[{{gj0, gjy}, {gy1, gjy}}]]
Out[8]=
If you redisplay an array of plots using Show, any options you specify will be used for the whole array, rather than for individual plots.
In[9]:= Show[%, Frame>True, FrameTicks>None]
Out[9]=
Here is a way to change options for all the plots in the array.
In[10]:= Show[ % /. (Ticks > Automatic) > (Ticks > None) ]
Out[10]=
GraphicsArray by default puts a narrow border around each of the plots in the array it gives. You can change the size of this border by setting the option GraphicsSpacing > h, v. The parameters h and v give the horizontal and vertical spacings to be used, as fractions of the width and height of the plots.
This increases the horizontal spacing, but decreases the vertical spacing between the plots in the array.
In[11]:= Show[%, GraphicsSpacing > {0.3, 0}]
Out[11]=
When you make a plot, Mathematica saves the list of points it used, together with some other information. Using what is saved, you can redraw plots in many different ways with Show. However, you should realize that no matter what options you specify, Show still has the same basic set of points to work with. So, for example, if you set the options so that Mathematica displays a small portion of your original plot magnified, you will probably be able to see the individual sample points that Plot used. Options like PlotPoints can only be set in the original Plot command itself. (Mathematica always plots the actual points it has; it avoids using smoothed or splined curves, which can give misleading results in mathematical graphics.)
Here is a simple plot.
In[12]:= Plot[Cos[x], {x, Pi, Pi}]
Out[12]=
This shows a small region of the plot in a magnified form. At this resolution, you can see the individual line segments that were produced by the original Plot command.
In[13]:= Show[%, PlotRange > {{0, .3}, {.92, 1}}]
Out[13]=
