MaplePortal/PlottingTips - Maple Help

Plotting Tips: Vertical Lines and Axis Labels

Go to Maple Portal

Introduction

Certain graphing techniques are essential in the classroom but are not covered by basic plotting examples in Maple.  Here, you will learn three interactive plotting strategies:

 • plot vertical lines
 • control axis labels (for instance, labels with multiples of $\mathrm{π}$)
 • create a graph interactively and then efficiently reuse that graph

These are not complicated techniques, and once you have discovered them you will be able to employ them to make better graphs for classroom presentations and handouts as well as save yourself time and effort.

Commands, context-sensitive operations, and the Plot Builder are discussed.  The Plot Builder is Maple's most robust interactive plotting tool.  It provides access to a variety of plot types and to the plot options that enable you to customize your graph.  As you change the options in the Plot Builder, preview your graph.  When you are satisfied, return a plotting command that can be reused and modified.  With the Plot Builder, your plots can be easier to read and convey more useful information.

Initializations

 > $\mathrm{restart}$
 > $\mathrm{with}\left(\mathrm{plots}\right):$

Plotting the Graph of a Vertical Line

In the $\mathrm{xy}$-plane, the graph of the solution set of the equation $x=1$ is a vertical line.  This line cannot be obtained as the graph of a function, so Maple's plot command will not graph the vertical line without user intervention.  Figure 1 shows a portion of this line drawn with the plot command as a line segment.  Figure 2 draws this same line segment as the parametric curve $x\left(t\right)=1,y\left(t\right)=t$.

 > $\mathrm{plot}\left(\left[\left[1,-1\right],\left[1,1\right]\right]\right)$

 > $\mathrm{plot}\left(\left[1,t,t=-1..1\right]\right)$

Figure 1   Graph of the vertical line segment by specifying its endpoints

Figure 2   Parametric plot of the vertical line segment


Clearly, graphing a vertical line segment via the plot command requires significant user intervention and knowledge of Maple syntax.  Figure 3 provides a graph of the vertical line segment drawn as an implicit plot with the implicitplot command from the plots package.

 > $\mathrm{implicitplot}\left(x=1,x=0..2,y=-1..1\right)$

Figure 3   Graph of the vertical line $x=1$ drawn as an implicit plot



For more information on these methods, see plot details and parametric plot

Figures 1 - 3 all require some mathematical insight on the part of the user, who must correspondingly implement some appropriate Maple construct that reflects that view of the vertical line.  Now what happens when the user naively tries to plot $x=1$ interactively via the Context Panel?  Select the equation $x=1$ and from the context-sensitive operations in the Context Panel, select Plots>2-D Implicit Plot>$\mathbit{x}\mathbf{,}\mathbf{\text{?}}$.

 $x=1$$\to$  Figure 4   Use of a context-sensitive operation to plot the vertical line $x=1$

The result is shown in Figure 4. You can obtain the graph through the Context Panel as well as by using a command.  A final way to graph a vertical line is using the Plot Builder.

First, launch the Plot Builder from the Tools>Assistants menu. In the Expressions section, click the Add button, and enter $x=1$.

Pressing the Accept button enters the equation $x=1$ into the Expression box and adds the variable $x$ to the Variables box.  See Figure 5.

 Figure 5   Specify the expressions and variables

Press OK. The Plot Builder panel appears.  For plot type, select 2-D implicit plot.  Again, you get the graph of the vertical line.  You can use the Plot Builder to further customize the plot, if desired.

 Figure 6   The Plot Builder graphs the line as a 2-D implicit plot

Controlling the Labeling of an Axis

Using the Context Panel

Consider the graph of $\mathrm{sin}\left(x\right)$.  On the horizontal axis, the default range ( for a trigonometric graph), default tickmarks, and default labels are shown.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right)\right)$

Figure 7   The default plot of $\mathrm{sin}\left(x\right)$

If you want to to change the tickmarks and labels on x-axis to whole number multiples of $\mathrm{π}$, you can do so after the graph has been drawn.

Click on the graph to select it, then in the Context Panel choose Axes>Properties.... (You can also access this from the Plot menu.)  The Axis Properties box is shown in Figure 8.

Under the Horizontal Axis tab, clear the box for Let renderer choose tickmarks, and instead select Custom Spacing (1.0) and Multiply by Pi.  The modified graph is shown in Figure 9.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right)\right)$

Figure 8   The Axis Properties

Figure 9 Modified graph with $\mathrm{π}$ in the labels

Graphing Efficiently: Return a Command You Can Reuse

Although creating one plot through the Plot Builder is convenient, if you are creating many plots, this can become a tedious way to create the modifications you want.  One tip for more efficient graphing is to use the Plot Builder once, and then extract command with all the settings you selected.

In the Plot Builder, you can opt to show the command used to create the plot.  This provides a way to learn the way to specify these options directly to the plot command.  If you intend to graph numerous similar functions with the same plot settings, this is an efficient way to do it.

For example, here we plot an ellipse using the Plot Builder, and return the command.  We then modify the command to plot two additional graphs.

Use the Context Panel to launch the Plot Builder for your expression.  In this example, we will graph $\frac{{x}^{2}}{49}+\frac{{y}^{2}}{9}=1$.

In the Plot Builder panel, select 2-D implicit plot for the plot type.  Select show command to see the plotting command. To force the axes to use the same scale, under 2-D Options, for scaling select constrained.

The result is shown in Figure 11.

 Figure 11   The plot and command returned from Plot Builder

Now, you can copy and paste this command on a new line (ensure you are in 2-D math mode when you paste it)  to create a graph.  You can modify the command to create variations.  For instance, you can graph $\frac{{x}^{2}}{9}+\frac{{y}^{2}}{9}=1$ or $\frac{{x}^{2}}{49}-\frac{{y}^{2}}{9}=1$ without having to go through the Plot Builder steps again.

1. Graph of $\frac{{x}^{2}}{9}+\frac{{y}^{2}}{9}=1$, a circle.

2. Graph of $\frac{{x}^{2}}{49}-\frac{{y}^{2}}{9}=1$, a hyperbola.