Part 4: Plotting - Maple Programming Help

Home : Support : Online Help : Getting Started : Tutorials : MaplePortal/Tutorial4

Part 4: Plotting

 Introduction Maple Tutorials are designed to help you get started with Maple, learn about the key tools available in Maple, and lead you through a series of problems.   In Part 4: Plotting, you will create 2-D and 3-D plots.  You will learn how to combine multiple plots and create animations.  You can create plots from the Context Panel, a command, or the Plot Builder Assistant.   To try this material on your own, start with an empty Maple document. Perform the steps described in the left column of each table below.  The results of the steps are displayed in the right column for reference.   Refer to Help > Quick Reference for basic getting started tips.   Note for non-Windows users: The keystrokes given in this document are for Windows.  There will be differences for other platforms. If you are using a different platform, see Shortcut Keys.

2-D and  3-D Plots

Maple can produce 2-D and 3-D plots of equations and expressions.

Steps

Result

2-D Plots

Learn to plot in Maple.  The fastest way to plot an expression in Maple is to use the Context Panel.

Example: Enter an expression in x (such as ), and then select Plots > 2-D Plot from the Context Panel.

Example: Use the point probe to find the coordinates of different points in the graph. From the Context Panel for the plot, select Probe Info>Nearest point on line. When you hover over a point on the graph, the coordinates are displayed.

Example: To pan the plot, click on the plot, and select Manipulator>Pan from the Plot menu or Context Panel. Hold down the left mouse button and use the mouse to move the plot around. To scale the plot, perform the same steps, but select Manipulator>Scale.

Tip: You can also change the manipulator tool by clicking on the plot, and then selecting the appropriate tool from the plot toolbar:

Example: Enter an expression in x (such as ${\mathrm{sin}}^{2}\left(x\right)$), and from the Context Panel for the expression, select Plots > 2-D Plot.

Observe that the default x-range for plots is -10 to 10 for most plots, but it is $-2\mathrm{π}$ to $2\mathrm{π}$ for trigonometric plots.



$\to$ 

${\mathrm{sin}}^{2}\left(x\right)$$\to$ 



Setting the Axis Properties for a Plot

The default $y$-range for a plot is chosen based on the values computed.  You can set the range after creating a plot by modifying the axis properties.

Example:  Click on the plot, then select the Axis Properties button  from the plotting toolbar.  For both the horizontal and vertical axes, you can set min and max values, set number of tickmarks, and control advanced features such as number of subticks.

Example: Modify the vertical range for the plot of  :  Click on the plot, then select the Axis Properties button  from the plotting toolbar.  Under the Vertical tab, clear the Use data extants check box, and change the Range min to -15.



$\to$ 



Combining Plots

You can easily add another plot on the same set of axes.

Example: Enter another equation in $x$ (such as $\mathrm{sin}\left(\frac{x}{2}\right)$), highlight the new expression with your mouse, and drag it onto the plot.

Tip: When you select and drag the expression onto the plot, the expression is deleted from its original position.  Another way to drag is to use the Copy and Drag feature:

 • Highlight the expression, hold [Ctrl], and drag it onto the plot.

For this and other tips, see the Quick Reference Card (Help>Quick Reference).



${\mathrm{sin}}^{2}\left(x\right)$$\to$ 



$\mathrm{sin}\left(\frac{x}{2}\right)$

Annotating Plots

You can add titles, captions, and legends to plots.  (From the Context Panel, select Title or Legend.)

You can also add additional information to plots by using the drawing tools.  Lines, arrows, text, 2-D math, and shapes are available.

Example: Click on the plot, then click on the  button on the toolbar. Use the text tool (T) to enter labels for the curves.  Use [F5] to toggle between text and math, and enter labels for the curves in Math mode.





Plotting with Commands

Example:  Graph a polynomial using the plot command.

Note that when you do not specify a range, the default $x$-range [-10, 10] is used.

Example:  Graph the polynomial again, this time specifying the range [-3, 5].  A range in Maple is given by a..b.

For more information and examples using the plot command, see plot.



$\mathrm{plot}\left({x}^{3}-4{x}^{2}-x+4\right)$

$\mathrm{plot}\left({x}^{3}-4{x}^{2}-x+4,x=-3..5\right)$



To display multiple plot structures into a single graph using commands, use plots[display].

Example:  Enter two plot commands.

Then use plots[display] to see both curves in a single graph.

$\mathrm{plot1}≔\mathrm{plot}\left(\mathrm{ln}\left(x\right),x=0..25\right):$

$\mathrm{plot2}≔\mathrm{plot}\left(\mathrm{ln}\left(x-5\right),x=0..25\right):$

$\mathrm{plots}\left[\mathrm{display}\right]\left(\left[\mathrm{plot1},\mathrm{plot2}\right]\right)$



Steps

Result

3-D Plots

You can create 3-D plots.

Example: Enter an expression in x and y (for instance, $\mathrm{sin}\left(x\right)\cdot y$ ). From the Context Panel for the expression use Plots > 3-D Plots > x,y.

Example: Rotate the plot by clicking on the plot, holding down the left mouse button and moving the mouse.

Example: Pan and scale the plot by selecting a different tool from the Manipulator list in the Context Panel.  Now when you hold down the mouse button and move the mouse, the new action is performed.

Tip: You can also change the manipulator tool by clicking on the plot, and then selecting the appropriate tool from the plotting toolbar:

Note that the default x-range and y-range for plots is -10 to 10 for most plots, but it is $-2\mathrm{π}$ to $2\mathrm{π}$ for trigonometric plots.





$\mathrm{sin}\left(x\right)\cdot y$$\to$ 

Plot Options

You can modify the look of your plot in a variety of ways.

Plot options can be changed by clicking on the plot and modifying the options in the Context Panel.  Note that the choices available in the Context Panel are specific to 3-D plots.

Example: Click on the plot to obtain the context-sensitive options.  Click Color and choose XY to modify the shading.

Example: Click on the plot, and then in the Context Panel select Axes>Boxed.

Plot options can also be changed by clicking on the plot, selecting the Plot menu, and selecting the relevant options.





$\mathrm{sin}\left(x\right)\cdot y$$\to$ 

Plotting in 3-D with Commands

Example:  Graph a polynomial using the plot3d command.

For more information on the plot3d command, see plot3d.

Note that when you do not specify a range, the default x-range and y-range for plots is -10 to 10 for most plots, but it is $-2\mathrm{π}$ to $2\mathrm{π}$ for trigonometric plots.





Plotting Guide

In addition to plot and plot3d, many other plotting commands are available. The PlottingGuide makes it easy to find the plot type you need. You can also access the plotting guide from Help > Maple Help > Table of Contents > Graphics > Plotting Guide.

Using the Plot Builder Assistant

Steps

Result

Plots can easily be created in Maple using the built-in Plot Builder.

Example: Enter the expression you want to plot.  In the Context Panel, select Plots>Plot Builder.  Using the Plot Builder, you can choose the kind of plot you want, add titles, and set options, all at once. This example uses the default options and adds a caption that uses 2-D math.

 1 For plot type, select 3-D plot.
 2 Select Axes and Text, and enter the caption $z={x}^{2}-{y}^{2}$.

The Plot Builder allows you to create more than just ordinary 2-D and 3-D plots.  The example on the right is a contour plot.

Example: Enter the expression ${x}^{2}+{y}^{2}$.  Select Plots>Plot Builder in the Context Panel.  Select 2-D contour plot for the plot type.

${x}^{2}-{y}^{2}$$\to$







${x}^{2}-{y}^{2}$$\to$



Using the Plot Builder to Return a Plot Command

Exercise:  Find the derivative of and plot the result.

 1 To enter the expression: Use symbol completion to create the exponential In Math mode, type e. press Esc, and select e (exponential) from the list.
 2 To compute the derivative:  In the Context Panel, choose Differentiate>with respect to t.
 3 To apply the Plot Builder: Select the output (the derivative) and in the Context Panel, select Plots>Plot Builder.
 4 For the plot type, select 2-D plot.
 5 Under the plot type, click the toggle button for show command.
 6 Modify the view so the $t$ range is 0..10 and the $y$ range is -2000..2000. The worksheet shows the plot and below it, the command for this plot.

Tip:  If you use the Plot Builder to create a plot and then return the plot command, you can easily modify and reuse this command.  To use the command, simply copy the command to a new line and execute.



$\frac{{ⅇ}^{t}}{t}$$\stackrel{\text{differentiate w.r.t. t}}{\to }$$\frac{{{ⅇ}}^{{t}}}{{t}}{-}\frac{{{ⅇ}}^{{t}}}{{{t}}^{{2}}}$$\to$

200

Exercise: Use the Plot Builder to create an interactive plot with 3 parameters for the expression $\mathrm{sin}\left(a\cdot x+b\right)+c$.