2-D Plots

One can develop a multitude of plots with
Maple. These plots can be function based,
point-by-point based, or any combination of
the two. One has a great deal of power in the
plot formats. For example, one can specify
discontinuous plots (*i.e.*, a plot of
the *tan* function), hide and shade
surfaces, normalize axis, etc.

Here is a simple parabola:

> plot((3*x^2-4),x=-10..10); A 300 + A AA + AA AA + AA AA 250 + A A + A A + A AA + AA A 200 + A A + A A + AA AA 150 + AA AA + AA AA + AA AA + AA AA 100 + AA AAA + AAA AAA + AAA AA 50 + AAA AAA + AAA AAA + AAA AAAAA + AAAAA +---+--+---+---+--+---+---+---+-***********-+---+---+---+---+---+---+--+---+ -10 -5 0 0 5 10

On an X-Window session, Maple opens up a second window containing the plot:

To plot two or more functions on one graph,
enclose the functions in curly brackets
**{}**.

One can define both the x and y values:

> plot({sin(x),x-x^3/6+x^5/120},x=-4..4); + A + A 1.5 + A + AA + A 1 + ********** A B + *** B*** AA BB + *** B**AAA AAA BB 0.5 + ** BB AA BB + ** BB BB +* BB +---+--+**-+---+--+---+---+---+--+-***---+--+---+---+---+--+---+--**--+---+ -4 BB -2 *0 0 2 BB 4 AAA BB -0.5 + BB AAA AAA*BB *** + BBB AA A***B *** + B A ********** -1 + AA + AA + A -1.5 + A + A +

Discontinuous and step functions can also be easily displayed:

> plot(tan(x),x=-2*Pi..2*Pi,-4..4,discont=true); C C 4 + C C CC C + C C C C + C C C C + C C C C + C C CC C 2 + CC C C CC + C CC CC CC + CC C CC CC + CC CC CCC CC + CCC CC ***-+-+--+-+-+--+-+**--+-+--+-+-+--+-***--+-+-+--+-+--+-**+--+-+-+--+-+-+-- CC CC* CC CCC -6 -4 CC -2 CC0 0 2 CC 4 CC6 CC CC + CC CC C CC + CC CC CC C + CC C C CC -2 + C CC C C + C C C C + C C C C + C C C C + C C C C -4 + C C

Maple allows one to compute much more complex
plots such as polar, spherical, and
cylindrical coordinates, conformal plots for
complex functions, and other specialized
graphics. To load these features, use the
`with(plots)`

command.

Lets look at a polar plot:

> with(plots, polarplot); [polarplot] > plots[polarplot](t); AAAAAAAAA 1.8 + AAAAAAAAA AAA AAA + AAA AAAA AAA AAA+AAA AAA AA 1.6A*A A AAA A+A AAA AA 1.4 + AA AA A AA + AA A AA 1.2 + A AA A A + A A A AA 1 + AA A A A + A A AA A + A AA AA A 0.8 + A AA A A + A A AA A 0.6 + A AA A A + A A AA A 0.4 + A AA A AA + AA A AA A + A AA A A0.2 + AA A A AA + A A -*-+-+--+-+-+-+--+-+-+-+--+-+-+-+--*****--+-+-+-+--+-+-+-+--+-+-+-+--+-+-*- -3 -2 -1 0 0 1 2 3

3-D Plots

**Note:** All 3-D plots will be shown as X-Window Session Images.

One can plot surfaces and 3-dimensional
objects with Maple. To do so, use the
`plot3d`

command. You need to
define all of the variables in your plot3d
statement. For example:

>plot3d((x^3)*sin(a*x^2),a=0..5,x=0..3,axes=BOXED);

Once the window opens with the plot, the mouse may be used to rotate the graph into any orientation. Pull-down menus allows one to choose between different surface renderings (hidden line, patch, contour, etc) and different light/color schemes. Some of these features are shown in the next figures.

A nice feature of Maple is the ability to
graph an equation without having to first
solve the equation based on any one variable.
The `implicitplot3d`

command is the
way to invoke this feature:

>with(plots); >implicitplot3d(x^3+5*y^2-z^3-8=0,x=-10..10,y=-10..10,z=-10..10);

The resulting surface is displayed below. Note that we can alter how the plots looks very easily:

Hidden Line (as entered in the command above).

Patched.

Point.

Contours.

Patched and Contoured.

One also has the option of plotting curves and
surfaces defined parametrically. Let us
define (for more information on functions, see
* Lesson 6, Algebraic Calculations) three
functions, F,G, and H:*

>F:=(u,v) -> sin(u)*cos(v); >G:=(u,v) -> sin(u)*sin(v); >H:=(u,v) -> cos(u);

Now letŐs plot these three functions
parametrically as a solid surface. We shall
*constrain* the scaling to preserve our
true spherical shape. **Note** that we
will include the three functions in square
brackets **[]**:

plot3d([F,G,H],0..Pi,0..2*Pi,style=PATCH,scaling=CONSTRAINED);

(we could have performed the entire feat in one statement):

>plot3d([sin(u)*cos(v), sin(u)*sin(v),cos(u)],u=0..Pi,v=0..2*Pi,style=PATCH,scaling=CONSTRAINED);

Saving and Printing Plots

As you have probably seen by now, the prefered method for displaying graphics is through an X-window session. But this does not mean that one cannot generate great looking plots via a text-only session. It just takes a little planning.

First off, you need to define your output
style. Usually, this will be a
postscript® file. Next, you will need to
define the output file name. The
`interface`

command is used to set
both of these paramaters:

>interface(plotdevice=postscript,plotoutput=myfile.ps);

Now, when you plot the graph, the output will go directly to the file. If you are ready to plot a second graph, be sure to specify a new file name:

>interface(plotoutput=myfile2.ps);

If you use the X-Windows Maple interface there
is a pulldown menu that you can take advantage
of. Under **File** there is a second menu
called** Printing**. This menu gives you
the option of saving your plot in a variety of
formats including postscript® (both color
and grey-scale), plotter formats, and GIF. Be
sure to check what your output looks like with
`xv`

.

This page Maintained by Dale H. Leschnitzer

Last Modified Monday, November 4, 1996

**L O S A L A M O S N A T I O N A L L A B O R A T O R Y***Operated by the University of California for the U.S. Department of Energy*