Plotting with Maple

The plot Command

The basic plot command:

> plot( 3*x^2 - x^4, x = -2 .. 2 );
3*x^2 - x^4 plot

Add a restriction on the range:

> plot( exp(x), x=-10..10, y=-10..10);
exp(x) plot

Plot several curves simultaneously:

> plot( {cos(x), 1 - x^2/2, 1 - x^2/2 + x^4/24}, x=-6..6, y=-2..2);
Multiple plot

Fill areas in various colors (one custom, one standard):

> plot([cos(x),4-x^2], x=-2..2, filled=true, color=[COLOR(RGB,.9,.9,.99), blue],scaling=constrained);
filled plot

Fill a more complicated area:

> plot([min(max(sin(x),cos(x)),0), max(min(sin(x),cos(x)),0), sin(x), cos(x)],
x=-8.75*Pi..11.25*Pi, filled=true, color=[white,white,red,red],
xtickmarks=[], scaling=constrained );
A more complicated plot

The plot3d Command

A basic 3D plot:

> plot3d( cos(x) + y^2/2, x=-10..10, y=-2..2);
3d plot

Add some options [most options can also be selected interactively, from menus]:

> plot3d( cos(x) + y^2/2, x=-10..10, y=-5..5,
scaling=constrained, style=patchcontour, axes=boxed,
orientation=[135,120], shading=none, lightmodel=light2, numpoints=2000);
3d plot with options

Plot a parametric curve in R2:

> plot( [ t*cos(t), t*sin(t), t = 0 .. 2*Pi ] );
parametric plot

and a parametric surface in R3:

> plot3d( [ r*cos(th), r*sin(th), cos(th)*sin(th) ],
r = 0 .. 1, th = 0 .. 2*Pi, grid = [10,60],
orientation=[100,25], shading=zhue, lightmodel=light2, style=patch);
z = x*y/(x^2 + y^2);
parametric surface plot

For more information on plot, plot3d, and their options, from the Maple Help menu do a Topic Search on plot. Select from any of approximately 100 related topics.

The plots Package

The "plots" package contains additional, more specialized plotting functions.

> with(plots):

Plot parametric curves in 3D:

> plotopts:= t=0..20*Pi, orientation=[0,60], numpoints=1000, scaling=constrained:
> p1:=spacecurve([cos(1.1*t)*(5+sin(t)),sin(1.1*t)*(5+sin(t)),cos(t)],
plotopts, shading=ZGREYSCALE, thickness=1):
> p2:=spacecurve([cos(2*t)*(5+sin(9*t)),sin(2*t)*(5+sin(9*t)),cos(9*t)],
plotopts, shading=zhue, thickness=3):
> display({p1,p2});
space curve plot

Display different types of plots, together:

> p1 := gradplot(x*y,x=-1..1,y=-1..1, color=blue):
> p2 := implicitplot( {x*y=.1, x*y=.2, x*y=.3, x*y=-.1, x*y=-.2, x*y=-.3},
x=-1..1, y=-1..1, color=red, thickness=2):
> p3 := textplot( [0, .75, `Gradients are normal to level curves!`],
font=[HELVETICA,BOLDOBLIQUE,14] );
> display({p1,p2,p3});
plot with gradients

Some elliptic curves, plotted together:

> plotopts := x=-5..5, y=-5..5, numpoints=2500, color=blue, thickness=2,
axes=boxed, xtickmarks=[-2,0,2,4], ytickmarks=[-2,0,2]:
> for i to 7 do
q.i := implicitplot(y^2 = x^3 + (4-i)*x^2,plotopts):
od:
> B := array(1..2,1..3,[[q1,q2,q3],[q4,q6,q7]]): display(B);
elliptics plot

A fancy 3D plot, using the tubeplot command:

> f:= [(t-5*Pi)*sin(t)/3, (t-5*Pi)*cos(t)/3, (t-5*Pi)*.9, t=0 .. 5*Pi]:
> tubeplot(f, radius = (t-5*Pi)*.2,
tubepoints = 25, style=PATCH
lightmodel=light3, shading=zhue, orientation = [-75,90]);
conchoid plot

This is one of many examples distributed with Maple.

Often there is more than one way to approach a problem.

> with(student); > showtangent(x^2, x=1);
plot with a tangent
> with(plots): with(plottools):
> p1:=plot(x^2, x = -1..2, thickness=2, color=green):
p2:=plot(2*x-1, x = .25 .. 1.75, thickness=3, color=blue):
p3:=circle([1, 1], .05, color=red, thickness=3):
p4:=textplot( [2, .25, `Slope = 2`], font=[HELVETICA,BOLDOBLIQUE,14] ):
p5:=arrow([1.65,.5],[-.5,.4],.05,.2,.2, color=red):
# On PCs, go to ^^^^^^ [1.05,.9] #
p6:=textplot( [2.5, 2, `y = 2 x - 1`], view=[-1..3, -1..4], font=[TIMES,ITALIC,10]):
> display({p1,p2,p3,p4,p5},scaling=constrained);
parabola