Contents Previous Next Index
6 Plots and Animations
Maple can generate many forms of plots, allowing you to visualize a problem and further understand concepts.
Maple accepts explicit, implicit, and parametric forms to display 2-D and 3-D plots and animations.
Maple recognizes many coordinate systems.
All plot regions in Maple are active; therefore, you can drag expressions to and from a plot region.
Maple offers numerous plot options, such as axis styles, title, colors, shading options, surface styles, and axis ranges, which give you complete control to customize your plots.
For a reference to the types of plots available in Maple, see the Plotting Guide.
6.1 In This Chapter
Creating Plots - Interactive and command-driven methods to display 2-D and 3-D plots
Interactive Plot Builder
The plot and plot3d Commands
The plots Package
Multiple Plots in the Same Plot Region
Customizing Plots - Methods for applying plot options before and after a plot displays
Interactive Plot Builder Options
Context Panel Options
The plot and plot3d Command Options
Analyzing Plots - Plot analyzing tools
Representing Data - Templates for visual representation of your data
The Live Data Plots Palette
Creating Animations - Interactive and command-driven methods to display animations
The plots[animate] Command
The plot3d[viewpoint] Command
Playing Animations - Tools to run animations
Animation Context Bar
Customizing Animations - Methods for applying plot options before and after an animation displays
Interactive Plot Builder Animation Options
Context Menu Options
The animate Command Options
Exporting - Methods for exporting plots
Saving Plots to File Formats
6.2 Creating Plots
Maple offers several methods to easily plot an expression. These methods include:
The Interactive Plot Builder
The context panel
Each method offers a unique set of advantages. The method you use depends on the type of plot to display, as well as your personal preferences.
The Interactive Plot Builder is a point-and-click interface to Maple plotting functionality . The interface displays plot types based on the expression you specify. Depending on the plot type you select, you can create a:
• 2-D / 3-D plot
• 2-D polar plot
• 2-D / 3-D contour plot
• 2-D / 3-D conformal plot of a complex-valued function
• 2-D / 3-D complex plot
• 2-D / 3-D parametric plot
• 2-D density plot
• 2-D / 3-D implicit plot
• 2-D inequality plot
• 3-D spacecurve
• 2-D animated curve
• 2-D / 3-D plot of multiple expressions
• 2-D / 3-D exploration of a plot with one interactive parameter (slider)
Launching the PlotBuilder
Context Panel Access
The Plot Builder can be launched using the context panel for an expression.
Click on the expression you'd like to plot and from the context panel select Plot Builder. In this case, the Plot Builder Panel opens.
This is equivalent to calling the PlotBuilder command on the expression.
The Plot Builder can also be accessed from the Standard Menu Bar, under Tools -> Assistants.
When launched in this way, an interactive dialog is displayed where you can enter the expression to be plotted. This is equivalent to calling the PlotBuilder command with no arguments.
Note: The Tools menu also offers tutors to easily generate plots in several academic subjects. For more information, see Teaching and Learning with Maple.
Example 1 - Display a plot of a single variable expression
Maple can display two-dimensional graphs and offers numerous plot options such as color, title, and axis styles to customize the plot.
Enter an expression:
Type the expression sin(x)/x.
From the Context Panel, select the Plot Builder:
From the Context Panel for the expression, select Plot Builder. The Plot Builder inserts plot component, with a plot of the expression, into the worksheet, and the Context Panel shows the Plot Builder options.
The automatically selected plot type for this expression is 2-D plot, and the panel is now populated with the available plotting options for a 2-D plot.
Ensure that the x-axis range is from −2 Pi..2 Pi.
When you return focus to your worksheet, you'll no longer see the Plot Builder controls. To make further modifications, click the output region of the displayed plot in the worksheet to again view the plot builder controls on the right.
Note: You can toggle the show command option to view the Maple syntax used to generate this plot.
Example 2 - Display a plot of multiple expressions in 1 variable
Maple can display multiple expressions in the same plot region to compare and contrast. The Interactive Plot Builder accepts multiple expressions.
Launch the Interactive Plot Builder and enter the expressions:
If the PlotBuilder is passed a list, set, or sequence containing multiple expressions then the context panel becomes automatically populated with a thumbnail view. The common plot type for expressions in a single unknown is a 2-D curve, and for expressions in two unknowns it is a 3-D surface plot.
As an example, use the PlotBuilder to plot sinx2, ⅆⅆx⁢sinx2 and ∫sinx2ⅆx.
Notice in the PlotBuilder window, from the thumbnail view you can change the common plot type for all expressions using the ListBox menu. You can select any individual thumbnail plot to change its associated properties or its own plot type in the PlotBuilder's usual individual plot view.
By default, Maple displays each plot in a plot region using a different color. You can also apply a line style such as solid, dashed, or dotted for each expression in the graph. For more information, refer to the plot/options help page. To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot Builder
Example 3 - Display a plot of a multivariate expression
Maple can display three-dimensional plots and offers numerous plot options such as light models, surface styles, and shadings to allow you to customize the plot.
Enter an expression, then launch the Interactive Plot Builder from the context panel:
Enter the expression (1+sin(x*y))/(x^2+y^2).
Launch the Plot Builder from the context panel.
In the Select Plot Type list:
Notice the available plot types for an expression with 2 variables, as well as the plot objects for each type. For this example, select 3-D plot.
Select Basic Options from the list of option types.
Restricting how much of the plot axes to display:
For the view option, select axis to adjust how much of the z-axis to display. Enter the range values in the two boxes. You can repeat this for the y-axis (axis) and x-axis (axis) as well.
Style and color changes:
From the Style combo box, select surface.
From the shading and color list box select shading, then select z (grayscale) from the color list box.
Select the Axes and Text menu.
In the text box next to label, enter z.
Select the 3-D Options menu
In the text box beside grid size, enter 40,40.
Example 4 - Display a conformal plot
Maple can display a conformal plot of a complex expression mapped onto a two-dimensional grid or plotted on the Riemann sphere in 3-D.
Enter the expression z^3.
Select 2-D conformal plot as the plot type.
Change the range of the z parameter to 0 .. 2+2*I.
From the axes style box, ensure normal is selected.
Select 2-D Options from the plot options list box, then enter [30,30] as the grid size.
Example 5 - Display a plot in polar coordinates
Cartesian (ordinary) coordinates is the Maple default. Maple also supports numerous other coordinate systems, including hyperbolic, inverse elliptic, logarithmic, parabolic, polar, and rose in two-dimensions, and bipolar cylindrical, bispherical, cylindrical, inverse elliptical cylindrical, logarithmic cosh cylindrical, Maxwell cylindrical, tangent sphere, and toroidal in three-dimensional plots. For a complete list of supported coordinate systems, refer to the coords help page.
Enter the expression 1+4*cos(4*theta).
Select the plot type and change the x-axis range:
Select 2-D polar plot as the plot type.
Change the angle of theta to 0 .. 8*Pi.
Change the plot color:
From the color group box, select magenta.
Example 6 - Interactive plotting
In this example, we'll make an animation of x+3⁢sinx⋅t, as t goes from 1 to 10.
Enter the expression x+3*sin(x*t).
Select the toggle button for animation.
The animation parameter is given under the animation toggle button. By default, this will animate as t goes from 1 to 10. (Note, if you wanted to animate over another variable, use this to specify that.
Set the x range to 0 to 5.
Click Build Animation.
Play the animation.
To play the animation, click the plot and the from the Animation Toolbar, select Play (
). For information on playing the animation, see Playing Animations.
Alternatively, you can use the exploration option in the Plot Builder to build an interactive plot with one parameter that you operate with a slider. For more about explorations, see Exploration Assistant.
The context panel is a collection of tools and operations that are appropriate for a particular expression. The plotting options in the context panel change according to the expression, table, or region that you click on.
One advantage of using the context panel is the simplicity of creating an expression using the tools and operations in the panel. By using this method, you do not need any knowledge of plot command syntax.
Enter and evaluate an expression, for example, x⋅yx2+y2.
Click the expression.
From the context panel, select Plots → 3-D Plot → x,y.
Figure 6.1: Plot an Expression Using the Context Panel
For information on customizing plots using the context menu, see Context Panel Options.
The plot and plot3d Commands
The final method for creating plots is entering plotting commands.
The main advantages of using plotting commands are the availability of all Maple plot structures and the greater control over the plot output. Plot options are discussed in Customizing Plots.
plot(plotexpression, x=a..b, ...)
plot3d(plotexpression, x=a..b, y=a..b, ...)
plotexpression - expression to be plotted
x=a..b - name and horizontal range
y=a..b - name and vertical range
Note: It's possible to not specify the ranges for the variables, in which case Maple determines a reasonable domain.
Maple commands from Creating Plots: Interactive Plot Builder
To display multiple expressions in a plot, include the expressions in a list. To enter ⅆⅆx⁡sin⁡x2⁢and ∫sin⁡x2ⅆx,⁢use the Expression palette. For more information, see Palettes.
Example 3 - Display a plot of a multivariable expression
Example 4 - Display a conformal plot
A collection of specialized plotting routines is available in the plots package. For access to a single command in a package, use the long form of the command.
Example 6 - Interactive Plotting
For more information on the plot options used in this section, refer to the plot/options and plot3d/options help pages.
Display a Parametric Plot
Some graphs cannot be specified explicitly. In other words, you cannot write the dependent variable as a function of the independent variable, y=fx. One solution is to make both the x-coordinate and the y-coordinate depend on a parameter.
plotcos3 t, sin5 t, t=0..2 π
Display a 3-D Plot
Maple can plot an expression of two variables as a surface in three-dimensional space. To customize the plot, include plot3d options in the calling sequence. For a list of plot options, see The plot and plot3d Options.
The plots Package
The plots package contains numerous plot commands for specialized plotting. This package includes: animate, contourplot, densityplot, fieldplot, odeplot, matrixplot, spacecurve, textplot, tubeplot, and more. For details about this package, refer to the plots help page.
The pointplot Command
To plot numeric data, use the pointplot command in the plots package with the data organized in a list of lists structure of the form x1,y1,x2,y2, ..., xn,yn. By default, Maple does not connect the points. To draw a line through the points, use the style = line option. For further analysis of data points, use the Curve Fitting Assistant (Tools→Assistants→CurveFitting), which fits and plots a curve through the points. For more information, refer to the CurveFitting[Interactive] help page.
The matrixplot Command
The matrixplot command plots the values of a plot object of type Matrix. The matrixplot command accepts options such as heights and gap to control the appearance of the plot. For more information on Matrices, see Linear Algebra.
The contourplot Command
The contourplot command generates a topographical map for an expression or function. To create a smoother and more precise plot, increase the number of points using the numpoints option.
Place your pointer over the graph to see the contour labels.
Dragging to a Plot Region
To add an additional curve to an existing plot region, use the drag-and-drop method.
Advantages of the drag-and-drop method include the ease of adding and removing plots and the independence from plotting command syntax.
Enter the command plotsinx,x in an input region.
Enter the expression sin2 x in an input region.
Drag the expression onto the plot of sinx. When dragging an expression to a plot region, you can either make a copy of the expression from the input region or you can cut the expression, thereby removing it from the input region. To make a copy of the expression, select the full expression in the input region and press Ctrl (Command, Macintosh) while you drag the expression to the plot region. To cut the expression and paste it in the plot region, highlight the expression and drag it to the plot region.
Repeat steps 3 and 4 using the following expressions: sinx+2and sinx2.
Tip: To remove an expression from the plot region, drag-and-drop the expression plot from the plot region to a Maple input region.
List of Expressions
To display multiple expressions in the same plot region, enter the expressions in a list data structure. To distinguish the surfaces, apply different shading options, styles, or colors to each surface.
The display Command
To display different types of plots in the same plot region, use the display command in the plots package.
This example plots a curve over a hill with the shadow of the curve projected onto the hill.
Maple can draw curves in three-dimensional space.
6.3 Customizing Plots
Maple provides many plot options to display the most aesthetically pleasing, illustrative results. Plot options include line styles, colors, shadings, axis styles, and titles where applicable. Plot options are applied using the Interactive Plot Builder, the context menus, or as options in the command syntax.
Interactive Plot Builder Options
The Interactive Plot Builder offers most of the plot options available in Maple in an easy-to-use interface.
Enter the expression, then launch the Plot Builder from the context panel:
Enter the expression 2*x^5-10*x^3+6*x-1.
Launch the Plot Builder from the context panel. For information on interacting with the Interactive Plot Builder, see Example 1 - Display a plot of a single variable expression.
Set the x-axis range:
Select 2-D Plot as the plot type.
Change the x-axis range to -2 .. 2.
In the Basic Options window:
From the line style list box, select dot.
From the color list box, select blue.
From the axes style list box, select frame.
In the Axes and Text window:
In the text field beside title, enter My Plot.
Using the options in the context panel, you can alter a plot by clicking the plot output. You can also access a large subset of plot options using the Plot toolbar and Plot menu options. These menus display when a plot region is selected. Regardless of the method used to insert a plot into Maple, you can use the context menu to apply different plot options. For a list of options available when plotting in two and three dimensions, see The plot and plot3d Options.
2-D Plot Options
Consider this example:
There is a singularity at x = 1. What are the x and y-intercepts? It's hard to see in the current view. If you change the range, the locations of the intercepts are easier to see.
Alter the y-axis range:
Click the plot region. From the context panel, select Axes, and then Properties.
In the Axes Properties dialog, click the Vertical tab.
Clear the Use data extents check box and enter -2 and 5 in the Range min and Range max text regions, respectively.
Click Apply to view the changes, or OK to return to the document.
Change the color:
Click on the curve. Note: The curve is selected when it becomes highlighted.
Select Color, and then Green.
Note: The Niagara colors listed form the default color palette in Maple.
Change the line style:
Select Line, and then Dash.
The x-intercept is at x=-2, and the y-intercept is at y=2. This can be verified using the equation y=x+2x−12.
3-D Plot Options
By default, Maple displays the graph as a shaded surface with a wireframe and scales the plot to fit the window. To change these options, use the context menu.
Maple has many preselected light source configurations.
Change the style:
Click the plot region. From the context panel select Style → Surface. The wireframe is removed.
Apply a light scheme:
Select Lighting → Light 1.
Change the axes style:
Select Axes → Boxed.
Alter the glossiness:
Select Glossiness and then select Set.... Using the slider, adjust the level of glossiness.
The plot and plot3d Options
If you are using commands to insert a plot, you can specify plot options as arguments at the end of the calling sequence. You can specify the options in any order. Applying plot options in the command syntax offers a few more options and greater control than what is available in the Interactive Plot Builder and the context panel.
Defines the type of axes, one of: boxed, frame, none, or normal
Defines the caption for the plot
Defines a color for the curves to be plotted
Defines the font for text objects in the plot
Controls the amount of light reflected from the surface
Defines gridlines in the plot
Controls the light model to illuminate the plot, one of: none, light1, light2, light3, or light4
Defines the dash pattern used to render lines in the plot, one of: dot, dash, dashdot, longdash, solid, spacedash, and spacedot
Defines a legend for the plot
Controls the minimum total number of points generated
Controls the scaling of the graph, one of: constrained or unconstrained
Defines how the surface is colored, one of: xyz, xy, z, zgrayscale, zhue, or none
Specifies the size (or ratio) of the plot window
Defines how the surface is to be drawn, one of: line, point, pointline, polygon, or polygonoutline for 2-D plots; contour, point, pointline, surface, surfacecontour, surfacewireframe, wireframe, or wireframeopaque for 3-D plots
Defines the symbol for points in the plot, one of: asterisk, box, circle, cross, diagonalcross, diamond, point, solidbox, solidcircle, or soliddiamond for 2-D plots; asterisk, box, circle, cross, diagonalcross, diamond, point, solidsphere, or sphere for 3-D plots
Defines a title for the plot
Defines the thickness of lines in the plot
Controls the transparency of the plot surface
Defines the minimum and maximum coordinate values of the axes displayed on the screen
For a complete list of plot options, refer to the plot/options and plot3d/options help pages.
plotSix,x=−20..20,title=Plot of the Sine Integral,titlefont=HELVETICA,12,color=Niagara 2,style=point
To create a smoother or more precise plot, calculate more points using the numpoints option.
6.4 Analyzing Plots
Point Probe, Rotate, Pan, and Zoom Tools
To gain further insight into a plot, Maple offers various tools to analyze plot regions. These tools are available in the Plot menu, Context Bar, and in the context menu (under Manipulator and Probe Info) when the plot region is selected).
Select a curve. For 2-D plots, select a coordinate type from the Selection Tool menu to display coordinates.
Use the Selection Tool to select the information displayed in the point probe tool tooltip. You can choose to display coordinates derived from converted pixel coordinates or data points derived from the original data points.
Rotate a three-dimensional plot to see it from a different point of view.
Pan the plot by changing the view ranges for 2-D plots; plots are redrawn to reflect the new view. Change the position of the plot in the plot region for 3-D plots.
Zoom into the plot; plots are redrawn to reflect the new view. Also, scale the plot by placing the pointer over the plot and then rotating the wheel button.
Zoom into a selected region by using a click-and-drag operation to select a rectangle.
Zoom out of the plot; plots are redrawn to reflect the new view. Also, scale the plot by placing the pointer over the plot and then rotating the wheel button.
Reset the view to the default view of the plot.
6.5 Representing Data
The Live Data Plots palette has templates that allow you to represent your data in many different ways including:
After you select a type of plot, an interactive environment allows you to change a number of options to refine the look of your plot. As you refine your plot, Maple automatically updates the plot command with your options.
If the Live Data Plots palette is not displayed in the palette dock, right-click on the palette pane, and select Show Palette, and then Live Data Plots.
6.6 Creating Animations
Animations allow you to emphasize certain graphical behavior, such as the deformation of a bouncing ball, more clearly than in a static plot. A Maple animation is a number of plot frames displayed in sequence, similar to the action of movie frames. To create an animation, use the Interactive Plot Builder or commands.
Creating Animations Using the Interactive Plot Builder:
Enter the expression sin(i*sqrt(x^2+y^2)/10).
Select Plot Builder from the context panel.
Select the Animation radio button.
The default x Axis range is -2*Pi .. 2*Pi. Change the x Axis range to -6 .. 6.
The default y Axis range is -2*Pi .. 2*Pi. Change the y Axis range to -6 .. 6.
Select i as the animation parameter from the drop-down list and the range to 1 .. 30.
From the Style group box, select surface.
From the Color group box, in the Shading drop-down menu, select z (grayscale).
In the 3-D Options window:
In the Scaling drop-down list, select constrained.
Build the Animation:
Click Build Animation
Click on the plot in the worksheet.
From the animation toolbar, click Start/Resume playing the animation.
For information on playing the animation, see Playing Animations. To see the Maple syntax used to generate this plot, see Maple Syntax for Creating Animations: Interactive Plot Builder Example.
The plots[animate] Command
You can also use the animate command, in the plots package, to generate animations.
animate(plotcommand, plotarguments, t=a..b, ...)
animate(plotcommand, plotarguments, t=L, ...)
plotcommand - Maple procedure that generates a 2-D or 3-D plot
plotarguments - arguments to the plot command
t=a..b - name and range of the animation parameter
t=L - name and list of real or complex constants
To access the command, use the short form name after invoking the with(plots) command.
Maple Syntax for Creating Animations: Interactive Plot Builder Example
The following example shows the plotting command returned by the example in Interactive Plot Builder.
Animate a 2-D plot
For more information on the animate command, refer to the plots[animate] help page.
The plot3d(...,viewpoint) Option
You can use the viewpoint option to create an animation in which the position from which you view a 3-D plot moves in all directions and in various angles around the plot surface based on coordinates and parameters you specify. This type of animation creates the effect of flying through, around, beside, towards, and away from a plot surface in three-dimensional space.
The moveable position from which you view the surface is called the camera. You can specify the orientation of the camera to view different sides of a surface, the path along which the camera moves throughout and around a surface, and the location of the camera in 3-D space in each animation frame. For example, you can specify coordinates to move the camera to specific points beside a surface; a pre-defined camera path to move the camera in a circle around the surface; and the range of view to move the camera close to or away from the surface. Refer to the viewpoint help page for more information.
To animate the following examples, click the plot object and then click the play button (
) in the Animation context bar.
Example 1: Moving the Camera Around a 3-D Plot
In the following example, a pre-defined path circleleft moves the camera in a counter-clockwise circle around the plot surface.
plot3d⁡1.3x⁢siny,x=−1..2 π,y=0..π,coords=spherical,style=patch, viewpoint=circleleft
Example 2: Specifying a Path to Move the Camera Towards and Around a 3-D Plot
In the following example, a camera path is specified to zoom into and view different sides of the plot surface.
6.7 Playing Animations
To run the animation, click the plot to display the Animate context bar.
View the previous frame in the animation.
Stop the animation.
Play the selected animation.
View the next frame in the animation.
Slider control for viewing individual frames of an animated plot.
Forward - Play the animation forward.
Oscillate - Play the animation forward and backward.
Backward - Play the animation backward.
Single - Run the animation in single cycle mode. The animation is displayed only once.
Continuous - Run the animation in continuous mode. The animation repeats until you stop it.
Frames per second
Set the animation to play at a faster or slower speed.
Execute click and drag code (2-D)
In an embedded plot window, use this probe to execute the specified click and drag code, if any.
Pan the plot by changing the view ranges.
Zoom into the plot. Also, scale the plot by placing the pointer over the plot and then rotating the wheel button.
Zoom out of the plot. Also, scale the plot by placing the pointer over the plot and then rotating the wheel button.
Reset the view to the default view of the 2-D plot.
Selection Tool (2-D)
Use the Selection Tool to select the information displayed in the point probe tool tooltip. You can choose to display coordinates derived from converted pixel coordinates or data points derived from the original data points. To copy the coordinate data into the clipboard, from the context panel select Probe Info → Copy data.
You can also run the animation using the context menu or the Plot menu.
6.8 Customizing Animations
The display options that are available for static plots are also available for Maple animations.
Interactive Plot Builder Animation Options
Using the Interactive Plot Builder, you can apply various plot options within the Plot Options window. See Interactive Plot Builder.
As with static plots, you can apply plot options to the animation by clicking the animation output.
Customize the animation using the context panel:
To change the line style, click the plot region. Select Style → Point.
To remove the axes, select Axes → None.
The animate command offers a few options that are not available for static plots. Refer to the animate help page for information on these additional options. By default, a two-dimensional animation consists of sixteen plots (frames) and a three-dimensional animation consists of eight plots (frames). To create a smoother animation, increase the number of frames using the frames option.
Note: Computing more frames increases time and memory requirements.
ball≔procx,y plotspointplotx,y, symbol=circle,symbolsize=20 end proc:
You can export a generated plot or animation to an image in various file formats, including DXF and X3D (for 3-D plots), EPS, GIF, JPEG/JPG, POV, and Windows BMP. Exporting an animation to GIF produces an animated image file. The exported images can be included in presentations, web pages, Microsoft Word, or other software.
To export an image:
Click the plot region.
From the context panel, select Export and the file format.
Click the plot.
From the Plot menu, select Export, and then the file format.
Maple has various plot drivers. By setting the plotdevice, a file can be automatically created without returning the image to the document. For more information, refer to the plot,device help page.
Download Help Document