plot3d

Maple's
plot3d command is used for drawing graphs of surfaces in three-dimensional space. The syntax and usage of the command is very similar to the plot command (which plots curves in the two-dimensional plane). As with the plot command, the basic syntax is

plot3d(what,how);

but both the "what" and the "how" can get quite complicated.

To plot the graph of z as a function of x and y, you can use the most basic form of the
plot3d command. For example, to get a plot of (the elliptic paraboloid) z = 3*x^2+y^2

>   restart:

>   z:=3*x^2+y^2;

z := 3*x^2+y^2

you can use a statement like:

>   plot3d(z, x=-2..2,y=-2..2);

[Maple Plot]

This is the plot as it is first produced. There are several things to notice. First, in the plot3d statement, the domains of both x and y must be specified.  Many other things can be specified, and we will discuss this below.

The next thing to notice is that the plot is produced without axes (and in peculiar colors on your color monitor or printer). But there are several things you can do to manipulate the appearance of the plot without typing any statements. You start by clicking on the plot itself -- this makes a square appear around the plot and you can use the handles on the square to resize the plot. There are two ways to manipulate the plot after that:

The first way is to use the buttons that appear near the top of the Maple window when you click on the plot -- The theta and phi buttons can be used to change the vantage point from which the plot is viewed, the next seven buttons provide different styles for the plot (these are explained more below), the next four give options for drawing axes, the 1:1 button forces the scales of the three axes to be the same (sometimes useful, sometimes not).

The second way is to click the RIGHT mouse button on the plot. This will display a menu from which you can choose "Style", "Axes", "Color", and/or "Projection"  for the plot. See below for descriptions  of this.

Changing the point of view: Viewing surfaces in space is different from viewing curves in the plane -- it depends where you look at the surface from (or how you turn the surface to look at it).  It takes some practice to get things just right, but after some experimenting, you will be able to produce nice surface plots. To do this, you can click on the plot itself, and then hold the mouse button down while moving the mouse. You will see the plot rotate as you change your point of view. As you do this, note that the values of theta and phi at the top of the Maple window will change as you rotate the plot. Once you are viewing the plot from the angle you want, note these values. Subsequently, you can make the plot using the "orientation=[theta,phi]" option (with theta and phi replaced by their values from the window) in order to get the plot from this point of view right


Changing the plot style:  There are several ways the plot can look -- you make a selection among several styles from the options menu or the command bar.  The styles that are most useful are:

1. Wireframe (6th of the seven buttons) -- these don't look the best, but Maple produces them the fastest, because it doesn't have to worry about which points are behind which. This is useful when you are trying to find just the right angle from which to view the surface. Then you can change to a different style that looks better.

2. Patch (with gridlines -- the first of the seven buttons)  -- Plots with this option look best in color and in black and white. Its drawback is that it takes longer to produce.

3. Hidden line removal (4th of the seven) -- Just as good as patch on black and white terminals (and in print), and doesn't take quite as long. This is the default plotting style.

4. Contour (and patch and contour -- 5th and 3rd of the seven choices respectively) -- shows the level curves of the surface. This can be VERY useful for identifying critical points. Here is that same surface with its contours drawn:

[Maple Plot]

Adding axes: With the "axes" option (or the next group of four buttons), you can add axes to the plot -- three styles, boxed, framed, and "normal" (i.e., the usual way one draws three-dimensional axes on paper) are available. It is interesting that the "normal" style is probably the least useful. Here is that plot again, with boxed axes:

[Maple Plot]

Notice that the axes are labeled (the third axis can also be labeled, we show how to do this below).

Using color:  The "XYZ" color style that is the default is pretty, but in some ways not so useful. A useful alternative is "Z" coloring , which colors points redder the higher they are (in z) and purpler the lower they are. An interesting way to make colored contour plots is to use Z coloring,  patch and contour style, boxed axes, and to view the plot from directly "above" -- this produces a useful contour map of the function under study. Here is such a picture for our elliptic paraboloid (this is black and white because it uses Z-grayscale coloring):

[Maple Plot]

Changing the scale:  We'll only discuss one of the options under the "perspective" menu -- the choice between "constrained" and "unconstrained" scaling. Unconstrained scaling is the default - in it, the axes are scaled differently so that the picture fills the plot window. For example, note above that the scale on the z-axis is profoundly different from that on the x and y axes. In "constrained" scaling, the axes are given the same scale. This can be helpful sometimes, although at other times it produces ludicrously tall skinny plots or short fat ones. You can experiment and get the idea.

-----

SOME VARIATIONS:

As with the two-dimensional
plot command, it is possible to draw more than one surface on the same picture by enclosing the list of functions to be plotted in braces, as follows:

>   plot3d({z, x*y} ,x=-2..2, y=-2..2);

[Maple Plot]

In plot3d the range of the third (z) axis must be specified using the view option as follows:

>   plot3d(z,x=-2..2,y=-2..2,view=-1..10,axes=boxed);

[Maple Plot]

Finally (as shown a little bit in the preceding statement), you can specify many of the options available in the menus (as discussed above) in the plot3d statement (the one that can be most useful is the style=WIREFRAME option, to get a fast first plot -- this can be overridden afterward using the menus):

>   plot3d(z,x=-2..2,y=-2..2,style=WIREFRAME,axes=BOXED);

[Maple Plot]


To see what other possibilities exist, you can look at the help screen for the
plot3d command.

Most of the common errors that occur when using
plot3d are similar to those for plot, so we will not repeat them here (yes, you can get "empty plot" messages here, too!).
-------

COMBINING PLOTS WITH display3d

You can exert somewhat more control over how plots are produced using the
display3d  command. Its use is similar to the display command, so our description here will be fairly brief. As with display, display3d must be loaded into memory as follows:

>   with(plots,display3d);

[display3d]

To use this command, you need to have one or more "plot structures" around -- these are 3D plots that have been assigned to variables (in statements that end with COLONs rather than semi-colons!). Here is an example where we plot a surface and its tangent plane at a point:

>   z:=3*x^2+y^2-x*y;

z := 3*x^2+y^2-x*y

We'll calculate the tangent plane at the point where x=1 and y=1. We'll need the values of z, and the partial derivatives of z there:

>   subs(x=1,y=1,z); subs(x=1,y=1,diff(z,x)); subs(x=1,y=1,diff(z,y));

3

5

1

So the equation of the tangent plane is:

>   tp:=3+5*(x-1)+1*(y-1);

tp := -3+5*x+y

Now, we make the "plot structures" for z and for tp -- we'll use different plot styles
so that the tangent plane is "transparent":

>   zplot:=plot3d(z,x=-1..2,y=-1..2,style=PATCH):

>   tpplot:=plot3d(tp,x=-1..2,y=-1..2,style=WIREFRAME):


Now we can use
display3d to display the two plots together:

>   display3d({zplot,tpplot});

[Maple Plot]


Notice that a lot of the vertical (z) range is taken up with an extraneous part of the tangent plane.  It is in situations like this when it is useful to exert some control in
display3d-- for example, we can restrict the dimensions of the axes using the "view" option (just as in 2D displays):

>   display3d({zplot,tpplot},view=[-1..2,-1..2,-1..12]);

[Maple Plot]

This is a somewhat more useful view of the same graphs, since the picture is more concentrated around the point of tangency.