MaplePortal/PlottingTips - Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : MaplePortal/PlottingTips


Plotting Tips: Vertical Lines and Axis Labels

Go to Maple Portal     Maple Portal for Math Educators




Plotting the Graph of a Vertical Line

Controlling the Labeling of an Axis

Graphing Efficiently: Return a Command You Can Reuse

See Also


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 π)


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-menus, 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.  Once you are satisfied, return a plotting command that can be reused and modified.  With the Plot Builder, your trigonometric plots can be easier to read and convey more useful information.




Plotting the Graph of a Vertical Line

In the 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 xt=1,yt=t.




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.



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 menu?  Right-click the equation x=1 and from the context menu, select Plots>2-D Implicit Plot>x,?.



Figure 4   Context menu plot of the vertical line x=1

The result is shown in Figure 4. You can obtain the graph through the context menu 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 will enter the equation x=1 into the Expression box and add the variable x to the Variables box.  In the Variables section, click the Add button and add the variable y.  Press Accept.  Figure 5 shows the completed Specify Expressions dialog.


Figure 5   Specify the expressions and variables

Press OK and then press Plot in the main Plot Builder window.  Again, you get the graph of the vertical line.


Figure 6   The Plot Builder now draws the plot as a 2-D implicit plot

Controlling the Labeling of an Axis


Using the Context Menu


Consider the graph of sinx.  On the horizontal axis, the default range (x=2 π..2 π for a trigonometric graph), default tickmarks (at multiples of π), and default labels are shown.


Figure 7   The default plot of sinx


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


Click on the graph to select it, then from the Plot menu choose Axes>Properties.... (You can also access this from the context menu for the plot.)  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.




Figure 8   The Axis Properties

Figure 9 Modified graph with π in the labels



Using the Plot Builder


When graphing with the Plot Builder, you can also access these options.  Use the context menu to launch the Plot Builder for your expression, such as  sinx.


In the Plot Builder, press the Options button to access the dialog for plot options, then select the Advanced Settings option under Axes on the lower left.  In the Advanced Axis Settings dialog box, open the drop-down listing under Tickmarks for the x-axis.  Select spacing(Pi, 0).





Figure 10   On the left, click Advanced Settings in the Axes box; on the right, in the x-row of the Axis box, click the down arrow in the Tickmarks column and select spacing(2, 0), the last item in the drop-down list.


Press the Apply button and then Plot.


Graphing Efficiently: Return a Command You Can Reuse

In the previous example, a plot was created through the Plot Builder.  If you are creating many plots, this can become a tedious way to create the modifications you want.  For more efficient graphing, you can use the Plot Builder once, and extract command with all the settings you selected.


When exiting the Plot Builder, instead of returning a plot, you can opt to return 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.  


Here are the steps to create the same plot as in the previous section and then to return a command from Plot Builder:

Use the context menu to launch the Plot Builder for your expression, such as sinx.

In the Plot Builder, press the Options button to access the dialog for plot options, then select the Advanced Settings option under Axes on the lower left.  In the Advanced Axis Settings dialog box, open the drop-down listing under Tickmarks for the x-axis.  Select spacing(Pi, 0).

Press Apply and then Command.


The result obtained from choosing Command instead of Plot is shown in Figure 11.



Figure 11   The 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 cosx without having to go through the Plot Builder steps again.


Some final illustrations of graphs obtained by modifying this command.


1. Graph of sinx and cosx.


2. One period of the graphs of sinx and cosx with constrained scaling.

plotsinx,cosx,x=0..2 π,tickmarks=spacingπ,0,default,scaling=constrained

3. Labeling every π4.

plotsinx,cosx,x=0..2 π,tickmarks=spacingπ4,0,default,scaling=constrained

For more information on tickmarks, including how to place one tickmark at a fixed location and then draw other tickmarks relative to that point, see plot/tickmarks.


4.  Using the Plot Builder to play with plot settings and preview the graph can be helpful with discontinuous graphs such as y=tanx.  When satisfied, return the command.




After returning the command from the Plot Builder, copy into a 2-D math region and execute.



To learn more about the options shown here as well as other options accepted by the plot command, see plot/options.

See Also

 plot, plot/options, plot/parametric, plot/tickmarks,  plots[implicitplot], plottools[line], trig


Go to Maple Portal     Maple Portal for Math Educators