Redrawing and Combining Plots

The Wolfram Language 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:

Plot[ChebyshevT[7,x],{x,-1,1}]

When you redraw the plot, you can change some of the options. This changes the choice of y scale:

Show[%,PlotRange->{-1,2}]

This takes the plot from the previous line, and changes another option in it:

Show[%,PlotLabel->"A Chebyshev Polynomial"]

By using (RefLink[Show, paclet:ref/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 (RefLink[Show, paclet:ref/Show]) to combine plots. All of the options for the resulting graphic will be based upon the options of the first graphic in the (RefLink[Show, paclet:ref/Show]) expression.

This sets gj0 to be a plot of (Subscript[J, 0])(x) from x==0 to 10:

gj0=Plot[BesselJ[0,x],{x,0,10}]

Here is a plot of (Subscript[Y, 1])(x) from x==1 to 10:

gy1=Plot[BesselY[1,x],{x,1,10}]

(RefLink[Plot, paclet:ref/Plot]) specifies an explicit (RefLink[PlotRange, paclet:ref/PlotRange]) for each graphic:

Options[gj0,PlotRange]

This uses (RefLink[PlotRange, paclet:ref/PlotRange]) to override the explicit value set for gj0:

gjy=Show[gj0,gy1,PlotRange->Automatic]

All Wolfram Language graphics are expressions and can be manipulated in the same way as any other expression. Doing these kinds of manipulations does not require the use of (RefLink[Show, paclet:ref/Show]).

This replaces all instances of the symbol (RefLink[Line, paclet:ref/Line]) with the symbol (RefLink[Point, paclet:ref/Point]) in the graphics expression represented by gj0:

gj0 /. Line->Point

Using (RefLink[Show, paclet:ref/Show])[(Subscript[plot, 1]),(Subscript[plot, 2]),…] you can combine several plots into one. (RefLink[GraphicsGrid, paclet:ref/GraphicsGrid]) allows you to draw several plots in an array.

Drawing arrays of plots.

This shows the previous plots in an array:

GraphicsGrid[{{gj0,gjy},{gy1,gjy}}]

If you redisplay an array of plots using (RefLink[Show, paclet:ref/Show]), any options you specify will be used for the whole array, rather than for individual plots:

Show[%,Frame->True,FrameTicks->None]

(RefLink[GraphicsGrid, paclet:ref/GraphicsGrid]) 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 (RefLink[Spacings, paclet:ref/Spacings])->{h,v}. The parameters h and v give the horizontal and vertical spacings to be used. The (RefLink[Spacings, paclet:ref/Spacings]) option uses the width and height of characters in the default font to scale the h and v parameters by default, but it is generally more useful in graphics to use (RefLink[Scaled, paclet:ref/Scaled]) coordinates. (RefLink[Scaled, paclet:ref/Scaled]) scales widths and heights so that a value of 1 represents the width and height of one element of the grid.

This increases the horizontal spacing, but decreases the vertical spacing between the plots in the array:

GraphicsGrid[{{gj0,gjy},{gy1,gjy}},Spacings->{Scaled[.3],Scaled[0]}]

When you make a plot, the Wolfram Language 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 (RefLink[Show, paclet:ref/Show]). However, you should realize that no matter what options you specify, (RefLink[Show, paclet:ref/Show]) still has the same basic set of points to work with. So, for example, if you set the options so that the Wolfram Language displays a small portion of your original plot magnified, you will probably be able to see the individual sample points that (RefLink[Plot, paclet:ref/Plot]) used. Options like (RefLink[PlotPoints, paclet:ref/PlotPoints]) can only be set in the original (RefLink[Plot, paclet:ref/Plot]) command itself. (the Wolfram Language 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:

Plot[Cos[x],{x,-Pi,Pi}]

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 (RefLink[Plot, paclet:ref/Plot]) command:

Show[%,PlotRange->{{0,.005},{.99999,1}}]