Detailed Information - Maple Help

Home : Support : Online Help : Graphics : 2-D : plot : Detailed Information

plot

create a two-dimensional plot of functions

 Calling Sequence plot(expr, x=a..b, opts) plot(f, a..b, opts) plot([expr1, expr2, t=c..d], opts) plot([f1, f2, c..d], opts) plot(m, opts) plot(v1, v2, opts)

Parameters

 expr - expression in x expr1, expr2 - expressions in t f, f1, f2 - procedure or operators x, t - names a, b, c, d - real constants m - Matrix or list of lists v1, v2 - Vectors or lists opts - optional arguments as described in the Options section

Basic Information

 • This help page contains complete information about the plot command. For basic information on the plot command, see the plot help page.

Description

 • The plot command is used to generate a curve from a function or a set of points in a 2-D plot.  If a function is provided, it may be specified as an expression in the plotting variable or as a procedure; alternatively, a parametric form of the function may be provided.

Plotting from an Expression or Procedure

 • The most common way to use the plot command is to use the first calling sequence, plot(expr, x=a..b), where an expression in one variable is specified over a given range on the horizontal axis. An example is plot(u^2-5, u=-2..3).
 • The second calling sequence is in operator form.  This allows you to use a procedure or operator to specify the function to be plotted.  The second argument, if given, must be a range; note that no variable name is used with operator form.  An example is plot(sin, -Pi..Pi).
 • If f is a procedure or operator, the first calling sequence, plot(f(x), x=a..b), is similar to but not the same as the second calling sequence, plot(f, a..b). The main difference is that with the first calling sequence, f(x) is first evaluated with the symbolic argument x, and then numeric values are substituted for x in the result; whereas with the second calling sequence, the numeric values are passed directly to the procedure f.
 • For the operator form, if the range is not provided, the default range is $-2\mathrm{\pi }..2\mathrm{\pi }$ for trigonometric functions and $-10..10$ otherwise. For the expression form, Maple has more complicated rules for finding a reasonable domain for the expression. For more information about plot ranges, see the plot/range help page. For more details about plotting functions, see the plot/function help page.

Using the Parametric Form

 • In the third calling sequence, plot([expr1, expr2, t=c..d]), the function is specified in parametric form.  The first argument is a list having three components: an expression for the x-coordinate, an expression for the y-coordinate, and the parameter range. For example, to plot a circle, use plot([sin(t), cos(t), t=0..2*Pi]).
 • The fourth calling sequence shows the operator-form of a parametric plot. Here, the first argument is a list containing two procedures or operators, specifying the x- and y-coordinates respectively, and a range.  For example, to plot a circle, use plot([sin, cos, 0..2*Pi]).

Plotting from Points

 • The last two calling sequences are for generating a curve from n points. In the calling sequence plot(m), m is an n by 2 Matrix or a list of n 2-component lists [u, v].  An example is plot([[0, 1], [1, 2], [2, 5], [3, 8]]).
 • In the calling sequence plot(v1, v2), v1 and v2 are two n-dimensional Vectors or two lists containing n numerical values.  They correspond to the x-coordinates and y-coordinates respectively.  An example is plot(Vector([0, 1, 2, 3]), Vector([1, 2, 5, 8])).
 • The Matrix, Vector, and list entries must all be real constants.  By default, a line going through the given points is generated. If you wish to see points plotted instead of a line, add the style=point option.

Generating Multiple Curves

 • Multiple curves can be plotted by replacing the first argument with a list or set of items, in every calling sequence except the last. Options such as color or thickness can be specified for each curve by using a list of values as the right-hand side of the option equation. In this situation, the first argument to the plot command must also be a list; if it is a set, the order of the plots might not be preserved.
 • A default color is assigned to each of the multiple curves. To customize the selection of colors, use the plots[setcolors] command.

Computational efficiency

 • For a discussion of computational efficiency of the plot command, and in particular its adaptive and redraw options, see plot/computation.

Interactive Plotting

 • Maple includes an Interactive Plot Builder.  Using the PlotBuilder command, you can build plots interactively.  For more information, see PlotBuilder and Using the Interactive Plot Builder.
 • Other interactive plotting commands are available in the Student and Statistics packages.

Options

 The opts argument shown in the Calling Sequence section above consists of a sequence of one or more plotting options.  The plot command accepts most of the 2-D plotting options described on the plot/options help page.  This section includes a brief summary of commonly used options.  See the plot/options help page for details on usage.
 • The view option is used to control the horizontal and vertical ranges that are displayed.  By default, the x-range in the calling sequences is used for the horizontal view.  You may optionally provide a y-range following the x-range; this is used for the vertical view but does not affect the values computed.  The scaling option allows you to constrain the scaling of the horizontal and vertical axes so they are equal.
 • The axes option controls the style of axes displayed.  Further control over the look of each axis is described in the plot/axis help page.  Gridline and tickmark options are described in the plot/tickmarks help page.  The labels option adds axes labels; if this option is not given, the default labels are the names (if provided) associated with the range arguments.
 • Options that affect the computation of the points that make up a curve include: discont for when the default methods for detecting points of discontinuity do not suffice, and numpoints to specify a minimum number of points.  The adaptive, resolution, and sample options give additional control over the sampling.
 • Titles and captions may be added with the title and caption options.
 • The look of a curve may be controlled with the color, thickness and linestyle options. Additionally, a legend entry may be provided for the curve with the legend option.  A list of values may be given for these options when multiple curves are being plotted.
 • When plotting points, use the style, symbol and symbolsize options to control the look of the points.
 • By default, the smartview option is set to true. In some cases, this causes the view of the data to be restricted so that the most important regions of the plot are shown.
 • Plotting may be done in an alternative coordinate system using the coords option.  For more information, see the plot/coords help page. It is recommended, however, that you use the plots[polarplot] command for plotting with polar coordinates.

Notes

 • The arguments to the plot function are evaluated numerically, not symbolically.  For more information about the computational environment used by the plot function, see plot/computation.
 • An empty plot may result if errors occur during the evaluation of the arguments to plot.  Errors generated during the evaluation of functions are replaced with the value undefined to allow the plots system to better handle singularities.
 • An empty plot can also be obtained by providing the empty list as the first argument expr or f in the first two calling sequences, or by omitting expr or f altogether.
 • Help pages describing plotting commands and interactive plotting features are written with the assumption that you are using the Standard Worksheet interface.  If you are using a different interface, see plot/interface.
 • An output device may be specified using the plotsetup command. See plot/device for a list of supported devices.
 • For three-dimensional plots, see plot3d.  Commands for generating specific types of plots, such as implicitly defined plots and plots on the complex plane, are found in the plots package.  Tools for manipulating plot elements are found in the plottools package.
 • A call to plot produces a PLOT data structure.  For more information, see plot/structure.

Examples

Using an expression to specify function to be plotted

Plot with a specified range:

 > $\mathrm{plot}\left(\mathrm{cos}\left(x\right)+\mathrm{sin}\left(x\right),x=0..\mathrm{Pi}\right)$

Plots without a specified range:

The default range is $-2\mathrm{\pi }..2\mathrm{\pi }$ for trigonometric functions.

 > $\mathrm{plot}\left(\mathrm{cos}\left(x\right)+\mathrm{sin}\left(x\right)\right)$

For other functions, more complicated rules apply. For example, for low degree polynomials, Maple ensures that the axis of symmetry of the graph is in the center of the plot.

 > $\mathrm{plot}\left({x}^{2}-6x\right)$

Using a procedure or operator to specify the function to be plotted

With a specified range:

 > $\mathrm{plot}\left(\mathrm{tan},-\mathrm{Pi}..\mathrm{Pi}\right)$

Without a specified range:

For trigonometric functions, the default range is $-2\mathrm{\pi }..2\mathrm{\pi }$.

 > $\mathrm{plot}\left(\mathrm{tan}\right)$

For non-trigonometric functions, the default range is $-10..10$.

 > plot(proc (x) if x < 2 and -1 < x then x^2 else x+2 end if end proc);

When using the procedure/operator calling sequence, it is only ever called with numeric values. Conversely, if you write f(x) for the expression in the expression calling sequence, this would normally cause a call to f with the symbolic variable x as the argument. Compare the two calling sequences in this example:

 > $f≔x→\mathrm{ifelse}\left(\mathrm{type}\left(x,'\mathrm{negative}'\right),-x,{x}^{2}\right)$
 ${f}{≔}{x}{↦}{\mathrm{ifelse}}{}\left({\mathrm{type}}{}\left({x}{,}'{\mathrm{negative}}'\right){,}{-}{x}{,}{{x}}^{{2}}\right)$ (1)
 > $\mathrm{plot}\left(f,-1..1\right)$
 > $\mathrm{plot}\left(f\left(x\right),x=-1..1\right)$

For the first calling sequence, this works as expected. In the second calling sequence, f is called with the symbolic variable x as the argument. This variable is not of type negative, so Maple chooses the second branch, ${x}^{2}$. This expression then gets all numeric values substituted into it.

Another way to plot this function as intended is to prevent evaluation using unevaluation quotes. This makes sure that the procedure is not called during the initial evaluation of the arguments to plot, but instead only once numeric values are substituted in.

 > $\mathrm{plot}\left('f\left(x\right)',x=-1..1\right)$

Generally, if you have an operator or procedure and calling it with symbolic arguments may be problematic, it is safest and easiest to use the operator calling sequence.

Plots using parametric form

Using expressions to write the functions.

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(t\right),\mathrm{cos}\left(t\right),t=-\mathrm{Pi}..\mathrm{Pi}\right]\right)$
 > $\mathrm{plot}\left(\mathrm{sin}\left(t\right),t\right)$

Note: The default range $-2\mathrm{\pi }..2\mathrm{\pi }$ is used for the last example since no range was specified.

 > $\mathrm{plot}\left(\left[{x}^{3},x,x=0..3\mathrm{Pi}\right],-8..8,-10..10,\mathrm{coords}=\mathrm{polar}\right)$

Using operator-forms.

 > $\mathrm{plot}\left(\mathrm{cos}+\mathrm{sin},0..\mathrm{Pi}\right)$
 > $\mathrm{plot}\left(\mathrm{tan},-\mathrm{Pi}..\mathrm{Pi}\right)$
 > $\mathrm{plot}\left(\mathrm{sin}\right)$
 > $\mathrm{plot}\left(\left[\mathrm{sin},\mathrm{cos},-\mathrm{Pi}..\mathrm{Pi}\right]\right)$

Generating multiple curves

Using a list to specify functions to be plotted:

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(x\right),x-\frac{1{x}^{3}}{6}\right],x=0..2,\mathrm{color}=\left["DarkGreen","NavyBlue"\right],\mathrm{style}=\left[\mathrm{point},\mathrm{line}\right]\right)$

Now, using a set to specify the same functions:

 > $\mathrm{plot}\left(\left\{x-\frac{1{x}^{3}}{6},\mathrm{sin}\left(x\right)\right\},x=0..2\right)$

Note that using a set to specify the functions might not preserve the order of the plots.

Point plots

 > $l≔\left[\left[n,\mathrm{sin}\left(n\right)\right]\$\left(n=1..10\right)\right]:$
 > $\mathrm{plot}\left(l,x=0..15,\mathrm{style}=\mathrm{point},\mathrm{symbol}=\mathrm{circle}\right)$

Alternatively, use the plots[pointplot] command to generate a plot of data points. See plots[pointplot] for more information.

Plots using polar coordinates

Method 1:

 > $s≔t→\frac{100}{100+{\left(t-\frac{\mathrm{Pi}}{2}\right)}^{8}}:$$r≔t→s\left(t\right)\left(2-\mathrm{sin}\left(7t\right)-\frac{\mathrm{cos}\left(30t\right)}{2}\right):$
 > $\mathrm{plot}\left(\left[r\left(t\right),t,t=-\frac{\mathrm{Pi}}{2}..\frac{3\mathrm{Pi}}{2}\right],\mathrm{numpoints}=2000,\mathrm{coords}=\mathrm{polar},\mathrm{axes}=\mathrm{none}\right)$

Method 2:

You can specify line thickness of the curve as well.

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(4x\right),x,x=0..2\mathrm{Pi}\right],\mathrm{coords}=\mathrm{polar},\mathrm{thickness}=3\right)$

Using various plot options

Use the optional argument opts to add a variety of plot options that customize the plot and axes labels, title, scaling, the look of a curve in terms of its thickness, color, style, and so on. For details, see the Options section.

Add a title and axes labels.

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right),x=-\mathrm{Pi}..\mathrm{Pi}\right],\mathrm{title}="A Circle in Cartesian Coordinates"\right)$

The default axes style is called normal. You can change the style to one of framed, boxed, or none.

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right),x=-\mathrm{Pi}..\mathrm{Pi}\right],\mathrm{axes}="framed"\right)$

A multiple function plot to demonstrate the color option.

 > $\mathrm{plot}\left(\left[\mathrm{sin}\left(x\right)\mathrm{cos}\left(x\right),\frac{1{x}^{2}}{5},\frac{1{x}^{2}}{7}\right],x=-\frac{1\mathrm{Pi}}{2}..\frac{1\mathrm{Pi}}{2},\mathrm{color}=\left["Blue","Magenta","Cyan"\right]\right)$

The tickmark option specifies the tickmark placement for the x-axis and y-axis respectively.

 > $\mathrm{plot}\left(\left[x,\mathrm{tan}\left(x\right),x=-\mathrm{Pi}..\mathrm{Pi}\right],-4..4,-5..5,\mathrm{tickmarks}=\left[8,10\right]\right)$

The options demonstrated here are only a few of all that can be applied to the plot command. For a comprehensive list, see plot/options.

Other examples

The default option settings detect discontinuities in most but not all expressions. See the plot/discont help page for details. Here is an example where the default settings detect the discontinuities.

 > $\mathrm{plot}\left(\mathrm{tan}\left(x\right),x=-2\mathrm{Pi}..2\mathrm{Pi},y=-4..4\right)$

Not in this example, though.

 > $\mathrm{plot}\left(-1+2\mathrm{Heaviside}\left(x-1\right),x=-1..2\right)$

In such cases, the discont option can be used.

 > $\mathrm{plot}\left(-1+2\mathrm{Heaviside}\left(x-1\right),x=-1..2,\mathrm{discont}\right)$

Infinity plot.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=0..\mathrm{∞}\right)$

Empty plots

 > $\mathrm{plot}\left(\right)$
 Empty plot with a specified boundary.
 > $\mathrm{plot}\left(x=0..2\mathrm{Pi},\mathrm{axes}=\mathrm{boxed}\right)$