Mathematica maintains separate commands for plotting functions expressed symbolically and expresses as a list. The basic plotting command for plotting functions of one variable is
Plot[f[x],{x,x_min,x_max}, PlotRange->{y_min,y_max},PlotPoints -> 30]Here we have included two of several options:
PlotRange
, which
controls which portion of the range to display; and
PlotPoints
, which controls the number of sample points to use
when plotting the function. The basic surface plotting command is
similar,
Plot3D[f[x,y],{x,x_min,x_max},{y,y_min,y_max}, PlotRange->{z_min,z_max}, PlotPoints -> {30,30}]
The commands to plot lists are similar. To plot a one-dimensional list, use
ListPlot[mylist,PlotRange->{y_min,y_max},PlotJoined->True]Notice that we do not have to specify the x range which determines the domain of the plot. Mathematica automatically uses the entire list.
PlotRange
and PlotJoined
are options. The default value
for PlotJoined
is False, which causes Mathematica to
plots points but not connect them. The command to plot a
two-dimensional list is
ListPlot3D[mylist,PlotRange->{z_min,z_max}]
In addition to plotting the graph of a function of two variables, we will also want to be able to plot the contour plot and the density plot of the functions. Including several options, these are:
ContourPlot[f[x,y],{x,x_min,x_max},{y,y_min,y_max}, Contours -> 20, ContourShading -> True, PlotPoints-> 30, ContourSmoothing -> Automatic]
Contours
controls the number of contours, ContourShading
shades the plot according to the values of the function,
PlotPoints
controls the number of sample points in each
direction, and ContourSmoothing
controls the smoothness of the
contours. Similarly, there is a command ListContourPlot
which
can be used to construct contour plots of two dimensional data sets.
ListContourPlot[mylist,Contours -> 20, ContourShading -> True, ContourSmoothing -> Automatic]The command for producing a density plot is:
DensityPlot[f[x,y],{x,x_min,x_max},{y,y_min,y_max}, Mesh -> False, PlotPoints-> 30]
Mesh
determines whether or not the grid lines are shown on the
plot. Similarly, there is command ListDensityPlot
,
DensityPlot[mylist,Mesh -> False]