plot3d - Maple Programming Help

Home : Support : Online Help : Graphics : 3-D : plot3d

plot3d

three-dimensional plotting

 Calling Sequence plot3d(expr, x=a..b, y=c..d, opts) plot3d(f, a..b, c..d, opts) plot3d([exprf, exprg, exprh], s=a..b, t=c..d, opts) plot3d([f, g, h], a..b, c..d, opts)

Parameters

 expr - expression in x and y f, g, h - procedures or operators exprf, exprg, exprh - expressions in s and t a, b - real constants, procedures, or expressions in y c, d - real constants, procedures, or expressions in x x, y, s, t - names opts - (optional) equations of the form option=value where option is described in plot3d/option

Description

 • The plot3d command computes the plot of a three-dimensional surface. The first two calling sequences describe surface plots in Cartesian coordinates, while the second two describe parametric surface plots.
 Other plotting facilities include the plot command for 2-D plotting, the plots package for specialized plots and the plottools package for plotting objects.
 For further resources for plotting, and a pictorial listing of the available types of plots, see the Plotting Guide. Note that this guide is only available in the Standard interface.
 • Maple includes the Interactive Plot Builder, which provides a point-and-click interface to the plotting functionality including two and three-dimensional plots, animations, and interactive plots with sliders. To launch the Plot Builder, run the plots[interactive] command. You can also launch the Plot Builder in the Standard Worksheet from the Tools menu. Select Assistants, and then Plot Builder. For more information, see Using the Interactive Plot Builder.
 • In the first calling sequence, plot3d(expr, x=a..b, y=c..d), the expression expr must be an expression in the names x and y. The range a..b must evaluate to real constants and the range c..d must either evaluate to real constants or be expressions in x. Alternatively, the range c..d must evaluate to real constants and the range a..b must either evaluate to real constants or be expressions in y. These specify the range over which expr is plotted.
 • In the second calling sequence, plot3d(f, a..b, c..d), f must be a procedure or operator that takes two arguments. Operator notation must be used, that is, the procedure name is given without parameters specified, and the ranges must be given simply in the form a..b, rather than as an equation. At least one of the ranges must have arguments evaluating to real constants; the other range may have arguments evaluating to real constants or be procedures of one variable.
 • A parametric surface can be defined by three expressions exprf, exprg, exprh in two variables. In the third calling sequence, plot3d([exprf, exprg, exprh], s=a..b, t=c..d), exprf, exprg, and exprh must be expressions in the names s and t. In the fourth calling sequence, plot3d([f, g, h], a..b, c..d), f, g, and h must be procedures or operators taking at most two arguments. As with the second calling sequence, operator notation must be used.
 • With any of these calling sequences, the range arguments may be omitted. In that case, the plot3d command assumes default ranges of -10 to 10, or $-2\mathrm{\pi }$ to $2\mathrm{\pi }$ in the case where a trigonometric function is detected. The first argument f or expr can also be omitted or set to the empty list [], in which case an empty plot is created.
 • Any additional arguments are interpreted as options, which are specified as equations of the form option = value. For example, the option grid = [m, n] where m and n are positive integers, specifies that the plot is to be constructed on an m by n grid at equally spaced points in the ranges a..b and c..d respectively. By default, a 49 by 49 grid is used and 2401 points are generated. Other options include specification of alternate coordinate systems and rendering styles. For more information, see plot3d/options.
 • If the first argument in any of the calling sequences is a set or list of surfaces, then the surfaces are plotted together. If a list is provided, then particular option values can also be given as lists, with elements corresponding to elements of the list of surfaces. The options that can take lists as values are: color, coords, grid, linestyle, numpoints, shading, style, symbol, symbolsize, thickness, and transparency. A list of three algebraic expressions or procedures is always interpreted as a parametric plot. To specify a list of three distinct plots, the option plotlist=true (or simply plotlist) must be provided.
 • Plots in alternative coordinate systems, such as spherical and cylindrical systems, can be generated by using the coords option. For more information, see the examples below or the plot3d/coords help page.
 • There are several ways to color 3-D surfaces created by the plot3d command. See the plot/color, plot3d/colorfunc and plot/colorscheme help pages for more information.
 • When plot3d evaluates its arguments, any errors generated during the evaluation are suppressed. A symptom that something has gone wrong with the evaluation of your expression is a resulting 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.
 • The result of a call to plot3d is a PLOT3D data structure containing enough information to render the plot. The user can assign a PLOT3D value to a variable, save it in a file, then read it in for redisplay. For more information, see plot3d/structure.
 • All plotted expressions are evaluated numerically, that is, as floating point expressions, rather than symbolically. For more information about the computational environment used by the plot3d function, see plot/computation.

Examples

Default ranges in 3-D plots

For trigonometric functions, default ranges of $-2\mathrm{\pi }$ .. $2\mathrm{\pi }$ is used.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right)\right)$

Default ranges of -10..10 are used when the range arguments are not provided.

 > $\mathrm{plot3d}\left(xy,y=0..1\right)$

Generating three-dimensional surfaces using expressions or procedures

When plotting an expression in two variables, the range for each variable must be provided in the form of x=a..b and y=c..d, where x and y are the variables used in the expression.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x+y\right),x=-1..1,y=-1..1\right)$

To plot a procedure that is a function of two variables (for example, binomial), give the procedure in operator notation (that is, without parameters). Also, the ranges must be given in the form a..b, not as equations.

 > $\mathrm{plot3d}\left(\mathrm{binomial},0..5,0..5\right)$

The following example defines a functional operator of two variables and plots it.

 > $f≔\left(x,y\right)↦{x}^{2}-{y}^{2}:$
 > $\mathrm{plot3d}\left(f,-1..1,-1..1\right)$

Using variable expressions or procedures in a range

You can specify a variable expression in one or both endpoints of a range as long as the other range contains real constants for both its endpoints. In the following example, the endpoints for x are given as real constants while the endpoints for y are expressions in x.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(xy\right),x=-\frac{\mathrm{\pi }}{2}..\frac{\mathrm{\pi }}{2},y=-x..x\right)$

Alternatively, the endpoints for y can be specified as real constants and the endpoints for x given as expressions in y.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(xy\right),x=-y..y,y=-\frac{\mathrm{\pi }}{2}..\frac{\mathrm{\pi }}{2}\right)$

The following example uses one procedure for the surface to be plotted and another procedure in the range for the second variable.

 > p:= proc(x,y) if x^2 < y then cos(x*y) else x*sin(x*y) end if end proc:
 > h:= proc(x) x^2  end proc:
 > $\mathrm{plot3d}\left(p,-2..2,-1..h\right)$

Drawing smoother curves with the grid option

The default 49 by 49 grid may be too coarse for a plot, especially if the surface changes rapidly over the plotting range.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)+\frac{\mathrm{sin}\left(20y\right)}{4},x=-\mathrm{\pi }..\mathrm{\pi },y=-\mathrm{\pi }..\mathrm{\pi }\right)$

Use the grid = [m, n] option to specify a finer grid and show more detail in your plot.

 > $\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)+\frac{\mathrm{sin}\left(20y\right)}{4},x=-\mathrm{\pi }..\mathrm{\pi },y=-\mathrm{\pi }..\mathrm{\pi },\mathrm{grid}=\left[50,200\right]\right)$

Specifying the surface color

The following command shows the default color for a three-dimensional surface.

 > $\mathrm{plot3d}\left(x\mathrm{exp}\left(-{x}^{2}-{y}^{2}\right),x=-2..2,y=-2..2,\mathrm{grid}=\left[100,100\right]\right)$

To set the color, use the color=cname option, where cname is one of the predefined plot color names.

 > $\mathrm{plot3d}\left(x\mathrm{exp}\left(-{x}^{2}-{y}^{2}\right),x=-2..2,y=-2..2,\mathrm{grid}=\left[100,100\right],\mathrm{color}="SkyBlue"\right)$

You can also set the color option to an expression or procedure, or use the colorscheme option to color by $z$ values.

 > $\mathrm{plot3d}\left(x\mathrm{exp}\left(-{x}^{2}-{y}^{2}\right),x=-2..2,y=-2..2,\mathrm{color}=x\right)$
 > $\mathrm{plot3d}\left(x\mathrm{exp}\left(-{x}^{2}-{y}^{2}\right),x=-2..2,y=-2..2,\mathrm{colorscheme}=\left["Blue","LimeGreen"\right]\right)$
 > p:= proc(x,y) if x^2 < y then cos(x*y) else x*sin(x*y) end if end proc:
 > h:= proc(x) x^2  end proc:
 > $\mathrm{plot3d}\left(p,-2..2,-1..h,\mathrm{color}=h\right)$

Displaying multiple surfaces in one plot

Use sets or lists to display more than one surface in the same three-dimensional plot.

 > $\mathrm{plot3d}\left(\left[\mathrm{sin}\left(xy\right),x+2y\right],x=-\mathrm{\pi }..\mathrm{\pi },y=-\mathrm{\pi }..\mathrm{\pi }\right)$
 > $\mathrm{c1}≔\left[\mathrm{cos}\left(x\right)-2\mathrm{cos}\left(0.4y\right),\mathrm{sin}\left(x\right)-2\mathrm{sin}\left(0.4y\right),y\right]:$
 > $\mathrm{c2}≔\left[\mathrm{cos}\left(x\right)+2\mathrm{cos}\left(0.4y\right),\mathrm{sin}\left(x\right)+2\mathrm{sin}\left(0.4y\right),y\right]:$
 > $\mathrm{c3}≔\left[\mathrm{cos}\left(x\right)+2\mathrm{sin}\left(0.4y\right),\mathrm{sin}\left(x\right)-2\mathrm{cos}\left(0.4y\right),y\right]:$
 > $\mathrm{c4}≔\left[\mathrm{cos}\left(x\right)-2\mathrm{sin}\left(0.4y\right),\mathrm{sin}\left(x\right)+2\mathrm{cos}\left(0.4y\right),y\right]:$
 > $\mathrm{plot3d}\left(\left\{\mathrm{c1},\mathrm{c2},\mathrm{c3},\mathrm{c4}\right\},x=0..2\mathrm{\pi },y=0..10,\mathrm{grid}=\left[25,15\right],\mathrm{color}=\mathrm{sin}\left(x\right)\right)$

To specify a different color for each surface, set the color option to a list of colors or expressions.

 > $\mathrm{plot3d}\left(\left[\mathrm{sin}\left(xy\right),x+2y\right],x=-\mathrm{\pi }..\mathrm{\pi },y=-\mathrm{\pi }..\mathrm{\pi },\mathrm{color}=\left["Navy",xy\right]\right)$

Plotting a parametric surface

If the first argument is a list of three surfaces, plot3d produces a plot of the parametric surface.

 > $\mathrm{plot3d}\left(\left[x\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right),x\mathrm{cos}\left(x\right)\mathrm{cos}\left(y\right),x\mathrm{sin}\left(y\right)\right],x=0..2\mathrm{\pi },y=0..\mathrm{\pi }\right)$

To not have a list of three surfaces interpreted as a parametric plot, either provide the plotlist=true option or use a set for the surfaces.

 > $\mathrm{plot3d}\left(\left[x\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right),x\mathrm{cos}\left(x\right)\mathrm{cos}\left(y\right),x\mathrm{sin}\left(y\right)\right],x=0..2\mathrm{\pi },y=0..\mathrm{\pi },\mathrm{plotlist}=\mathrm{true}\right)$
 > $\mathrm{plot3d}\left(\left\{x\mathrm{sin}\left(y\right),x\mathrm{cos}\left(x\right)\mathrm{cos}\left(y\right),x\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right)\right\},x=0..2\mathrm{\pi },y=0..\mathrm{\pi }\right)$

Using different coordinate systems

Use the coords option to specify a different coordinate system for your plot. See plot3d/coords for a list of the available coordinate systems and information on how they are interpreted by plot3d. The coords page gives a description for each of these coordinate systems.

The following three commands show plots using spherical and toroidal coordinates.

 > $\mathrm{plot3d}\left({1.3}^{x}\mathrm{sin}\left(y\right),x=-1..2\mathrm{\pi },y=0..\mathrm{\pi },\mathrm{coords}=\mathrm{spherical}\right)$
 > $\mathrm{plot3d}\left(\left[1,x,y\right],x=0..2\mathrm{\pi },y=0..2\mathrm{\pi },\mathrm{coords}=\mathrm{toroidal}\left(10\right),\mathrm{scaling}=\mathrm{constrained}\right)$
 > $\mathrm{plot3d}\left(\left[1,x,y\right],x=0..2\mathrm{\pi },y=0..2\mathrm{\pi },\mathrm{coords}=\mathrm{toroidal}\left(10\right),\mathrm{scaling}=\mathrm{constrained},\mathrm{style}=\mathrm{contour}\right)$

The following command generates the plot of the Möbius strip from the Plotting Guide using cylindrical coordinates.

 > $\mathrm{plot3d}\left(\left[4+x\mathrm{cos}\left(\frac{1}{2}y\right),y,x\mathrm{sin}\left(\frac{1}{2}y\right)\right],x=-\mathrm{\pi }..\mathrm{\pi },y=0..2\mathrm{\pi },\mathrm{coords}=\mathrm{cylindrical},\mathrm{style}=\mathrm{patchnogrid},\mathrm{grid}=\left[60,60\right],\mathrm{orientation}=\left[35,135\right],\mathrm{lightmodel}=\mathrm{light4},\mathrm{shading}=\mathrm{zhue},\mathrm{scaling}=\mathrm{constrained},\mathrm{transparency}=0.3\right)$

Drawing smoother edges with the adaptmesh option

Surfaces which are not defined over the entirety of a supplied rectangular domain can be drawn with smoother edges by supplying the adaptmesh option.

 > $\mathrm{plot3d}\left(\mathrm{sqrt}\left(1-{x}^{2}-{y}^{2}\right)+\frac{\mathrm{sqrt}\left({\left(x-\frac{1}{3}\right)}^{2}+{\left(y-\frac{1}{2}\right)}^{2}-\frac{1}{4}\right)}{2},x=-1.1..1.1,y=-1.1..1.1,\mathrm{adaptmesh}\right)$

Generating empty plot

 > $\mathrm{plot3d}\left(\mathrm{title}="An empty plot"\right)$

Compatibility

 • The plot3d command was updated in Maple 2015.