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