Plotting Graphs

>    restart:

1.  Plotting a functional expression.

>    f:=x^2;

Note:  To guard against input error, I recommend entering an expression to be plotted separately as above.

f := x^2

>    plot(f,x);

[Maple Plot]

2.  For simple graphs, specifying ranges of the variables, color of the graph, and permitting discontinuities.

>    f:=1/x;

f := 1/x

>    plot(f,x=-5..5,y=-10..10,color=black, discont=true);

[Maple Plot]

3.  Piecewise-defined functions

>    f:=piecewise(x<-2,x^2,x>=-2 and x<3,x,exp(x));

f := PIECEWISE([x^2, x < -2],[x, -2-x <= 0 and x < 3],[exp(x), otherwise])

>    simplify(%);

PIECEWISE([x^2, x < -2],[x, x < 3],[exp(x), 3 <= x])

>    plot(f,x=-5..5,y=-3..50,discont=true);

[Maple Plot]

4.  Data points.

>    plot({[-1,1],[2,3],[3,5]},x,style=point);

[Maple Plot]

5.  Labelled points, labelled axes.

>    PLOT(POINTS([-1,1]),POINTS([2,3]),POINTS([3,5]),TEXT([-1,1],'`(-1,1)`',ALIGNRIGHT,
ALIGNBELOW),TEXT([2,3],'`(2,3)`',ALIGNRIGHT,ALIGNBELOW),TEXT([3,5],'`(3,5)`',
ALIGNRIGHT,ALIGNBELOW),VIEW(-2..4,-1..6),TEXT([0,6],'`g(x)`',ALIGNABOVE,ALIGNRIGHT),
TEXT([4,0],'`x`',ALIGNRIGHT));

Note:  Maple is case-sensitive; therefore, capital letters must  be used in the foregoing command.

[Maple Plot]

6.  Implicitly defined curves.

>    eq:=x^2*y^2=(y+1)^2*(4-y^2);

Note:  To plot the curve defined by this equation, the plots  package must be loaded.  Hereafter, this requirement will be indicated by explicitly loading the package.

eq := x^2*y^2 = (y+1)^2*(4-y^2)

>    with(plots):

Warning, the name changecoords has been redefined

>    implicitplot(eq,x=-5..5,y=-2..2,numpoints=1500);

Note:  The number of points has been increased from the default in order to draw a smoother curve.

[Maple Plot]

7.  Polar coordinate graphs

>    r:=1+sin(t);

r := 1+sin(t)

>    with(plots):

>    polarplot(r,t=0..2*Pi);

[Maple Plot]

8.  Parametric curves

>    x:=2*(t-sin(t));   y:=2*(1-cos(t));

x := 2*t-2*sin(t)

y := 2-2*cos(t)

>    plot([x,y,t=0..4*Pi],scaling=constrained);

Note the location of the range equation; experiment to see what happens if it should be outside the brackets.  

The graph below was constrained , meaning that the same scale is on both axes; the default is unconstrained , meaning that Maple chose different scales on the two axes to give a better picture.  All the preceding graphs were unconstrained.  To change from one to the other:  click on the graph; then it is bordered by a box, and a graphics toolbar appears.  In this toolbar is a button labelled 1:1; click on it to toggle from one representation to the other.

[Maple Plot]

>    x:='x': y:='y':

9.  To generate graph paper.

>    with(plots):

>    coordplot(polar,scaling=constrained);  coordplot(cartesian,color=[black,green],scaling=constrained);

The graph paper below is constrained.  The default colors are red and blue (as in the polar graph).

>   

[Maple Plot]

[Maple Plot]

10.  Three-dimensional graph.

>    f:=sin(x*y)*cos(x+y);

Note:  This graph does not require the plots  package.  The default number of point plotted is 625.

f := sin(x*y)*cos(x+y)

>    plot3d(f,x=-Pi..Pi,y=-Pi..Pi,numpoints=1000);

[Maple Plot]

11.  Three-dimensional graph of implicitly defined surface.

>    ell:=x^2/9+y^2/25+z^2/49=1;

>    implicitplot3d(ell,x=-7..7,y=-7..7,z=-7..7,numpoints=2000);

ell := 1/9*x^2+1/25*y^2+1/49*z^2 = 1

[Maple Plot]

12.  Animations.

>    f:=a*x^2;

f := a*x^2

>    with(plots):

>    animate(f,x=-4..4,a=-3..3,frames=100);

[Maple Plot]

Note:  To evoke the context bar , which is used to control the animation, click on the animation.

13.  Three-dimensional animations.

>    with(plots):

>    f:=sin(t*x)*cos(t+y);

f := sin(t*x)*cos(t+y)

>    animate3d(f,x=-Pi..Pi,y=-Pi..Pi,t=-2*Pi..2*Pi,frames=100);

[Maple Plot]

>   

>   

>   

Note:  To evoke the context bar , which is used to control the animation, click on the animation.