Part 4: Plotting - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

Part 4: Plotting

Go to Maple Portal     Previous Tutorial     Next Tutorial

 

Introduction

2-D and  3-D Plots

Using the Plot Builder Assistant

See Also

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 a context menu, 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 Help > Quick Help for the list of the most common keystrokes.

 

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 menu.

 

Example: Enter an expression in x (such as 6 xx2), right-click on the expression, and select Plots > 2-D Plot.

 

Example: Use the point probe to find the coordinates of different points in the graph. Right-click on the plot, then 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, right-click on the plot, and select Manipulator>Pan. 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 sin2x), right-click on the expression, and select Plots > 2-D Plot.

 

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

 

6 xx2

 

sin2x  

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  6 xx2:  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.

 

 

6 xx2  

Combining Plots

 

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


Example: Enter another equation in x (such as sinx2), 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).

 

 

 

 

 

sin2x  

 

sinx2

Annotating Plots

 

You can add titles, captions, and legends to plots.  (From the context menu, 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.

plotx34x2x+4

plotx34x2x+4,x=3..5

 

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.

 

 

plot1plotlnx,x=0..25:

plot2plotlnx5,x=0..25:

plotsdisplayplot1,plot2

 

Steps

Result

3-D Plots

 

You can create 3-D plots.

 

Example: Enter an expression in x and y (for instance, sinxy ).  Right-click on the expression and use Plots > 3-D Plots > x,y from the context menu.

 

 

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 on the context menu.  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π to 2π for trigonometric plots.

sinxy

Plot Options

 

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

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

 

Example: Right-click on the plot to obtain the context menu.  Click Color and choose XY to modify the shading.

 

Example: Click on the plot, and then from the context menu select Axes>Boxed.

 

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

 

 

sinxy    

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π to 2π for trigonometric plots.

plot3dx2y2,x=2..2,y=2..2 

 

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.  From the context menu, 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 shows the use of plot title, normal axes and the style surface with contour.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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 x2+y2.  Select Plots>Plot Builder from the context menu.  Select 2-D Contour Plot from the Select Plot list box, then click Plot.

 

x2+y2  

x2+y2  

You can also create an animation using the Plot Builder assistant.


Example:  Enter the expression on the right, right-click to invoke the context menu.

 

Select Plots>Plot Builder.  Select Animation from the Select Plot Type drop-down list and click the Plot button.

 

Now click on the plot image.  The animation toolbar is now available.  Click the Play button  and watch the animation.  To step through the frames of the animation, click .

sinax2+y2π2    

 

Using the Plot Builder to Return a Plot Command

Exercise:  Find the derivative of ⅇ ttand 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:  From the context menu, choose Differentiate.

3. 

To apply the Plot Builder: Select the output (the derivative) and choose the Plot Builder.  Modify the view so the t range is 0..10 and the y range is -2000..2000.  Preview the result.  When you are done, click Command to return the plot command.

 

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.

ⅇttdifferentiate w.r.t. tⅇttⅇtt2plotⅇttⅇtt2,t=0..10,view=DEFAULT,2000..2000,labels=t,y

 

Exercise: Use the Plot Builder to create an interactive plot with 3 parameters for the expression sinax+b+c.

See Also

Animation Toolbar, Overview of Plotting, plot, plot3d, plots[display]. Plot Builder, Plot Toolbar, Plotting Guide

 

Go to Maple Portal     Previous Tutorial     Next Tutorial


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam