Graphing

In a maple worksheet, enter the following, to see pages of plot examples with detailed information.
  ?plottingguide 
This one source of information is recommended, because it can resolve issues about what to do in order to obtain the desired plot. Memorize plot and plottingguide for future lookup of key examples.

Rectangular Coordinate Plots, Multiple Plots

# STANDARD COORDINATES
# Maple can construct many kinds of graphs, a feature that you can use to
# visualize mathematical objects and processes. The command

 plot( sin(3*x), x = -Pi..Pi );

# produces a plot containing the curve y = sin(3 x) for x in the
# interval from -Pi to Pi. 

# No space is allowed between the double-dots in a plot command. Scales
# on the x-axis and y-axis are chosen in the maple engine.  To change
# this behavior:

 plot( sin(3*x), x = -Pi..Pi, scaling = constrained );

# Sometimes it is useful to restrict the range over which y varies.  We
# get a misleading graph from

 plot( tan(x), x = -5..5 );

# It does not accurately represent the vertical asymptotes of y = tan(x).
# Better results are obtained with

 plot( tan(x), x = -5..5, y = -2..2 );
 plot(tan,-5..5,-2..2); # Same result with less typing

# MULTIPLE CURVES ON ONE PLOT
# To plot y = sin(x) and y = sin(3 x) one a single axis, code
 
 plot( { sin(x), sin(3*x) }, x = -Pi..Pi ); 

# The curve equations are inside set-delimiters of curly braces
# You can also use square brackets, helpful for assigned colors.

 plot([sin(x),sin(3*x)],x = -Pi..Pi,color=[red,blue] ); 

# Decimal points can conflict with double-dot range parsing 

  plot(1+x^2,x=1 .. 0.8); # Compare syntax x=1...8

# THE PLOTS PACKAGE
# The DISPLAY command is found in the PLOTS package.
# It allows you to assemble several plots onto one set of axes.

 with(plots):
 plot1 := plot(x^2,x=0..4): # Colon to omit graphic display
 plot2 := plot(3*x^2-2,x=0..4):
 display([ plot1,plot2]);
 

Parametric, Polar and Raw Data Plots

# PARAMETRIC EQUATIONS
# A curve in the plane can be described as the graph of a function, as in
# the graph of 
#                           1     /     2\
#                       y = - sqrt\4 - x /
#                           2             
# for x in the interval from -1 to 1. It can be given parametrically as
#  
#               (x(t), y(t)) = (2 cos(t), sin(t))
#
# for t in the interval from 0 to Pi. Often we interpret such a curve as
# the path traced by a moving particle at time t . Use the plot command
# to draw a curve from this parametric description:

 plot( [2*cos(t), sin(t), t = 0..Pi] ); 
   # unconstrained, distorted graphic
 plot( [2*cos(t), sin(t), t = 0..Pi], scaling = constrained);  
   # constrained is not distorted

# POLAR COORDINATES
# Polar plots are a special kind of parametric plot.  The polar
# coordinates ( r, theta ) of points on a curve can be given as a
# function of some parameter t. In many cases the parameter is just the
# angle theta. Consider the ellipse defined in standard coordinates by
#
#                         x^2  + 4 y^2  = 4
#
# To find an equation relating the polar coordinates r and theta of a
# typical point on this ellipse, we make the substitution x = r cos(t)
# and y = r sin(t), where t = theta.

 subs( x = r*cos(t), y = r*sin(t), x^2 + 4*y^2 = 4);
 simplify( % );
 solve( %, r );

# We find that the ellipse is the collection of points whose polar
# coordinates ( r, theta ) satisfy
#
#                      2           4        
#                     r  = -----------------,
#                                          2
#                          4 - 3 cos(theta) 
#
# and the following commands draw the right half of the ellipse:

 r := 2/sqrt( 4 - 3*cos(t)^2 ):
 plot( [ r, t, t = -Pi/2..Pi/2 ], coords = polar );
 
# Here are some more of examples of polar plots that you can try:

 plot( [ 1, t, t = 0..2*Pi], coords=polar ):
 plot( [t, t, t = 0..2*Pi], coords=polar ):
 plot( [ sin(4*t), t, t = 0..2*Pi], coords=polar ): 
   # a more realistic picture is obtained with scaling = constrained.

# PLOTTING RAW DATA

# Maple can plot data consisting of pairs of x and y values.  For
# example, the double list

 data := [ [0, 0.53], [1, 1.14], [2, 1.84], [3, 4.12] ];

# defines data as a sequence of five data points.
# A double list is something enclosed in square brackets, with
# comma-separated elements in square brackets. Lists are used
# for collections of objects where the order matters.

 data[1]; data[2]; data[3]; data[4]; 
   # Individual items are accessed this way
 data[3][2]; 
   # Extract 2nd coordinate 1.84 from the 3rd data point [2,1.84]

# To plot the points in a double-list we use commands like

 plot(data); # The simplest interface to plotting points.

 plot(data,opts); # Plot with an option definition like
 opts:=style = point, symbol = circle, color = black;
 opts:=style = line, view = [0..4, 0..5];
 opts:=style = line, title = "Experiment 1";

# The double quote is used to specify a plot title string.  See
# ?plot[options] for more information, e.g., about symbols and line
# styles available. See ?plottingguide for ideas and examples.

# Display help ?readdata and ?writedata to find out how
# to read or write a file of data points into a Maple session.

Graphs in Three Dimensions

# EXAMPLE. Graphing functions of two variables.
 f:=(x,y)->x^2-y^2;
 plot1:=plot3d(f(x,y),x=-1..1,y=-1..1,color=blue):
       # Graph of z=x^2-y^2
 plot2:=plot3d([.5*cos(theta),.5*sin(theta),z],
          theta=0..2*Pi,z=0..1,color=pink):
       # Graph of a cylinder, defined parametrically                    
 plot3:=plot3d(.5,x=-1..1,y=-1..1,color=brown): 
       # A horizontal plane z=0.5
 with(plots):
 display([plot1,plot2,plot3],axes=boxed);  
       # Click on the plot to move it around in space.
       # A box in upper left of window will display
       # the spherical coordinates you're looking from!

# EXAMPLE. Implicit plots.
 with(plots): f:=(x,y)->x^2-y^2;
 implicitplot(f(x,y)=.5,x=-1..1,y=-1..1,color=black); 
       # The level curve where x^2-y^2=.5
 with(plots):g:=(x,y)->3*x^2-2*x*y+5*y^2:  
       # A quadratic function of two variables
 implicitplot(g(x,y)=1,x=-2..2,y=-2..2,color=blue,grid=[80,80]);
       # Default grid unappealing, needed better resolution.