Section 9.7 Assigning Plots and the display() Command
You can use the assignment operator to assign just about any type of output to a variable name, including plots. This can be useful when different types of plots need to be displayed on the same graph. You can assign the output of several
plot() commands to variables and then βdisplayβ them all on the same set of axes.
To make use of the
display() command, you need to include the plots package. Packages are loaded using the with() command, where the name of the package appears within the parentheses.
A package does not need to be loaded more than once in your document. However, you will need to reload the package if you have previously closed the document.
> with( plots );
\begin{align*}
\amp [animate,animate3d,animatecurve,arrow,changecoords, \\
\amp complexplot,complexplot3d,conformal,conformal3d,contourplot, \\
\amp contourplot3d,coordplot,coordplot3d,densityplot,display, \\
\amp \vdots \\
\amp spacecurve,sparsematrixplot,surfdata,textplot,textplot3d,tubeplot]
\end{align*}
Loading a package will typically display all of the commands that are included in the package. However, if a full colon is added, then the package is loaded but the output is hidden.
> with( plots ):
With the
plots package loaded, plotting options can be defined for each plot individually and assigned to a name. Full colons are recommended at the end of each line to hide the output of the individual plot. The display() command handles the job of combining the output of the multiple plots together.
> p1(x) := (x+2)^2 + 2*(x+2) - 5;
\begin{equation*}
\displaystyle p1\, := \,x\mapsto \left( x+2 \right) ^{2}+2\,x-1
\end{equation*}
> p2(x) := 3*(x-4)^3 - 2*(x-4)^2 - (x-4) + 1;
\begin{equation*}
\displaystyle p2\, := \,x\mapsto 3\, \left( x-4 \right) ^{3}-2\, \left( x-4 \right) ^{2}-x+5
\end{equation*}
> p3(x) := x - 3;
\begin{equation*}
\displaystyle p3\, := \,x\mapsto x-3
\end{equation*}
> A := plot(p1(x), x=-6..0, y=-6..3, linestyle=dot): > B := plot(p2(x), x=-0..10, y=-10..10, style=point): > C := plot(p3(x), x=-10..10, y=-10..10): > display([A,B,C]);
