Classroom Tips and Techniques: ContextMenu Plotting
Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft
Introduction
The Context Menu for a Maple mathematical expression in a single variable provides two distinct options for plotting. In this month's article, we examine these options and provide a rationale for guiding the choice between them.
ContextMenu Plotting Options
The Plots option in the Context Menu for an expression such as provides three relevant choices amongst the five shown in Figure 1. These are 2D Plot, 3D Plot, and Plot Builder. In a word, the first option invokes the smartplot command; the second, the smartplot3d command; the third, the plot command. The 2D Plot option and the Plot Builder provide a planar graph of the curve . The 3D Plot option and the Plot Builder provide a graph of the developable cylinder with generator parallel to the axis.

Figure 1 Options for plotting via Context Menu: Plots

The functionality of the plot and smartplot commands differs slightly, and it is these differences we wish to explore.
The smartplot Commands
Figure 2 shows the application of the smartplot command to , the equivalent of selecting 2D Plots in the Context Menu. The resulting graph is drawn on the default range . A range option for cannot be be given. The plot will always be drawn on this range.

Figure 2 The smartplot command applied to

To obtain the graph on, say, , use the Context Menu for the graph, selecting Axes/Properties as per Figure 3.

Figure 3 Axis Properties from the Context Menu of the graph in Figure 2

Uncheck the box to the left of "Use data extents" and type new endpoints into the boxes labeled "Range min" and "Range max". Note that must be entered as 6.28 because (at the present time) the ContextMenu modifications can contain neither arithmetic calculations nor symbolic constants. Clicking the OK button will change Figure 2 to Figure 4.

Figure 4 The ContextMenu modified version of Figure 2.

The inability to obtain a graph on precisely the interval , would seem to be a grave defect in the use of the smartplot. However, there is a significant redeeming feature of this command.
If the Context Menu option Axes/Properties is used to increase the range of the graph in Figure 4, say to , the smartplot retains knowledge of the function and the additional data points needed to draw the graph on the extended range can be recomputed. I call this the "rescalable axis" property, and it is illustrated in Figure 5 where the Context Menu for Figure 4 was used to rescale the horizontal axis beyond even the original default bound.

Figure 5 Horizontal axis in Figure 4 rescaled by Context Menu

Another strength of the smartplot command is its ability to graph implicitly. Figure 6 shows the result of applying this command to the equation of the unit circle. Again, application of this command is equivalent to selecting 2D Plot from the Context Menu.

Figure 6 An implicitly drawn graph via the smartplot command.

A final feature of a graph generated by the smartplot command is the retention of the plot window under the draganddrop plotting option. Thus, to add the graph of an additional function to an existing graph, draganddrop (or copy/paste) the expression for the rule of the function onto the graph. Figure 7 shows the result of dropping onto the graph in Figure 4; Figure 8, the result of dropping onto the graph in Figure 6; and Figure 9, the result of dropping onto a modified Figure 6.



Figure 7 Drop onto Figure 4

Figure 8 Drop onto Figure 6

Figure 9 Drop onto modified Figure 6

The modification of Figure 6 that results in Figure 9 is the "freezing" of the plot window in Figure 6. The Axes/Properties dialog must be invoked via the Context Menu, and as per Figure 3, the existing endpoints (both horizontal and vertical) of and 1, must be "locked in" by clicking the Apply button for both directions.
It is also possible to modify Figure 8 to look like Figure 9. Just use the Axes/Properties dialog from the Context Menu for Figure 8. Starting from Figure 6, the net amount of "work" needed to create Figure 9 is the same in either event. And clearly, the passage of Figure 4 to Figure 7 retained the plot window of Figure 4 because that window had been set by the adjustment to the default window that generated Figure 4.
The cylinder , in Figure 10 can be drawn with the Context Menu by selecting Plots/3D Plots/x,?, which implements the smartplot3d command. In general, with either of or missing, defines a generalized cylinder, that is, a developable surface with generator parallel to the coordinate axis of the missing variable.
Initially, the graph is the one in Figure 11, but the Context Menu options for this graph can be used to transform the image to the one seen in Figure 10.


Figure 10 The smartplot3d command draws the cylinder

Figure 11 The initial graph of the cylinder , provided by the smartplot3d command

The Plot Builder
When , is graphed by the Plot Builder launched from the Context Menu, it is possible to set the plotting range before generating the plot. Moreover, endpoints such as 2*Pi or sqrt(2) are admissible. Figure 12 shows the Plot Builder settings that produce the desired graph.

Figure 12 ContextMenu launched Plot Builder for

The Preview button on the lower right provides a preview of the graph. When the preview pane is closed, control is returned to the Plot Builder so additional modifications can be made. Thus, before the graph is embedded in the worksheet, the plot and the plot window can be adjusted until they are optimal.
The graph of produced by the Plot Builder is generated with the plot command. At the present time, such plots do not retain the rule of the function in the plot data structure. Hence, interactive rescaling changes an axis, but does not recompute any new points from which a new graph is to be drawn. For example, if is graphed on , and then the Context Menu for this graph used to change the plot window to , the result will be the graph shown in Figure 13.

Figure 13 Interactively enlarging plot window in a graph generated by plot command

In essence, this observation suggests that when using the Plot Builder, it's best to use the Preview option to set the plot window appropriately before embedding the graph. Enlarging the plot window via the graph's Context Menu does not work, but shrinking it (where no new points need to be computed) certainly does work.
A graph drawn by the plot command will retain its plot window under draganddrop plotting. Figure 14 shows the result of dropping onto the graph of , that was drawn by the Plot Builder (which itself uses the plot command).

Figure 14 Draganddrop onto graph of , drawn by plot command

The plot window does not revert to the default interval . Unfortunately, this is not the case for the implicit plot, based on the implicitplot command, drawn by the Plot Builder. Figure 15 shows the Plot Builder's Preview for , the unit circle. The default plot window is , and the test points used by the implicitplot command are uniformly distributed over this region. Hence, too few fall on (or near) the circle. Figure 16 shows the graph that results when the plot window is changed (in the Plot Builder) to . Finally, Figure 17 gives the result of dropping onto Figure 16.



Figure 15 Implicit plot of unit circle drawn by Plot Builder using default plot window

Figure 16 Implicit plot of unit circle drawn by Plot Builder with plot window

Figure 17 Graph resulting from dropping onto Figure 14

The plot window for the implicitly drawn graph reverts to the default window of the function added to the graph. In this case, the default is that of the plot command, namely, the interval .
Figure 10 can be drawn with the Plot Builder if the Edit Functions button is clicked. Figure 18 shows the pane that opens, and in which is added as a second variable in the Add Variables region.

Figure 18 Adding to the list of variables in order to draw the cylinder , with the Plot Builder

Summary
Table 1 summarizes our findings for the plot (and implicitplot) commands behind the Plot Builder option in the Context Menu/Plots choices, and for the smartplot behind the 2D Plot option (or smartplot3d behind the 3D Plot option).
Property


Rescalable axis

Window safe under draganddrop

Algebraic or symbolic endpoints

Cylinder


Plot Builder

plot

implicitplot

no

no

yes

no

yes

yes

yes

N/A


smartplot

explicit

implicit

yes

yes

yes

yes (*)

no

no

yes

N/A


Table 1 Comparison of Plot Builder and smartplot options in the Context Menu selection Plots. (*)  the functionality is available only if the plot window has been "frozen".

The smartplot and smartplot3d commands:
(+) expanding the horizontal axis "grows" the graph of the function
(+) if first "frozen," plot window is preserved under draganddrop plotting
() algebraic and symbolic endpoints not allowed
() Axes/Properties dialog not userfriendly
() Context Menu modifications must be applied onebyone, each requiring a relaunch of the Context Menu
The Plot Builder:
(+) plot window for explicit plot preserved under draganddrop plotting
(+) algebraic and symbolic endpoints are allowed
(+) Preview button and rangechange dialog very userfriendly
(+) all plot options available in one pane via the Options button
() plot window for implicit plot not preserved under draganddrop plotting
() expanding the horizontal axis does not "grow" the graph of the function after leaving the Plot Builder
Consequently, it was, and still is, this author's opinion that the Plot Builder is the toolofchoice for interactive graphing.
Legal Notice: The copyright for this application is owned by Maplesoft. The application is intended to demonstrate the use of Maple to solve a particular problem. It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft.