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
Code for Color Plates - Information on color plates
Accessing Code for the Color Plates
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
Launching the PlotBuilder
The Plot Builder can 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.
Context Panel Access
The Plot Builder can also 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.
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.
Launch the Interactive Plot Builder:
Make sure that the cursor is in a Maple input region.
From the Tools menu, select Assistants, and then Plot Builder.
Notes: In worksheet mode, Maple inserts PlotBuilder() in the Maple document and opens the Specify Expressions window.
Entering this command at the Maple prompt also opens the Plot Builder.
Enter an expression:
In the Interactive Plot Builder:Specify Expressions window:
Add the expression, sin(x)/x.
Click Accept in the Add/Edit Expression window.
Click OK in Interactive Plot Builder:Specify Expressions window.
Display the PlotBuilder panel and plot the expression:
The PlotBuilder inserts an empty plot component into the worksheet, just under the PlotBuilder() command. Click on this to make the PlotBuilder panel slide into view.
Select 2-D plot from the list of available plot types for this expression. Notice the rest of 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.
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:
The Plot Builder accepts expressions in 1-D Math and performs basic calculations on expressions. For example, entering diff(sin(x^2), x) in the Specify Expression window performs the calculation and displays the expression as 2*cos(x^2)*x in the Expression group box.
In three separate steps:
Launch the PlotBuilder then add the expression sin(x^2). Select 2-D Plot as the plot type. Change the x-axis range to -Pi..Pi
Launch another instance of the PlotBuilder and add the expression diff(sin(x^2),x). Select 2-D Plot as the plot type. Change the x-axis range to -Pi..Pi
Launch a third instance of the PlotBuilder and add the expression int(sin(x^2), x). Select 2-D Plot as the plot type. Change the x-axis range to -Pi..Pi
You should have three separate plots in separate plot component windows.
Assigning the plot commands to a name
Click on the plot of sin(x^2) to display the PlotBuilder panel for this plot.
In the assign to name text field enter "a".
Click the plot of diff(sin(x^2),x)
In the assign to name text field enter "b".
Click the plot of int(sin(x^2),x)
In the assign to name text field enter "c".
Use the plots[display] command to plot the expressions on the same axis
In your worksheet enter plots[display](a,b,c) then run the command.
The expressions are all plotted on the same axes.
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 multi-variate 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.
Launch the Interactive Plot Builder and enter an expression:
Add the expression (1+sin(x*y))/(x^2+y^2).
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.
Add 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.
Add 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
Using the Interactive Plot Builder, you can plot an expression with several of its variables set to numeric values. The Interactive Parameter window allows you to interactively adjust these numeric values within specified ranges to observe their effect. To access this window, enter an expression with two or more variables and select Interactive Plot with x parameter from the Select Plot Type and Functions drop-down menu.
Figure 6.1: Interactive Parameter Window
At the command prompt, type plots[interactive]() then add the expression x+3*sin(x*t).
From the Select Plot drop-down box, select Interactive Plot with 1 parameter.
Change the range of the x-axis to 0 .. 2*Pi.
Change the t range to 0 .. 10.
Click Plot to place the interactive plot in the Maple document.
Note: To apply plot options before interactively adjusting the plot, click Options.
You can also click Preview to preview your interactive plot from the Plot Builder.
To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot Builder.
For information on customizing plots using the Interactive Plot Builder, refer to Customizing Plots: Interactive Plot Builder Options.
You can also explore an interactive plot with parameters using the Exploration Assistant. For more information, 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.
When you invoke the Interactive Plot Builder through the context panel, the expression automatically passes to the builder, and Maple does not display the Specify Expression window.
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.2: 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 multi-variable 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
To play the animation, click the plot and the from the Animation Toolbar, select Play (
). For information on playing the animation, see Playing Animations.
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.