plot  create a twodimensional 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 2D 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^25, 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).

•

With both calling sequences, if the range is not provided, the default range is for trigonometric functions and otherwise. 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 xcoordinate, an expression for the ycoordinate, 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 operatorform of a parametric plot. Here, the first argument is a list containing two procedures or operators, specifying the x and ycoordinates respectively, and a range. For example, to plot a circle, use plot([sin, cos, 0..2*Pi]).

•

For more information about parametric plots, see the plot[parametric] help page.



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 2component 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 ndimensional Vectors or two lists containing n numerical values. They correspond to the xcoordinates and ycoordinates 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 righthand 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.



Interactive Plotting


•

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 2D 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 xrange in the calling sequences is used for the horizontal view. You may optionally provide a yrange following the xrange; 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 avoiding points of discontinuity, 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.

•

Providing an empty set or list as the first argument also results in an empty plot.

•

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 threedimensional 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


>


>


>


>


Since no range is specified in the last example, the default range is used.
Using the same four plots, but as procedures or operators:
>


>


>


>


For expressions having discontinuities over finite intervals you can:
>


>


Multiple plots (in a set or list):
>


Infinity plots
>


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


 (1) 
>


Other plots
>


>


>


Polar coordinates (with thickened curve)
>




See Also


discont, fdiscont, plot, plot/color, plot/computation, plot/device, plot/discont, plot/function, plot/infinity, plot/interface, plot/multiple, plot/options, plot/parametric, plot/range, plot/structure, plot/style, plot3d, plotinterface/interactive, plots[display], plots[interactive], plots[pointplot], plots[polarplot], plots[setcolors], plotsetup

