Notice! This document is currently in Archived status.
The content of this document may be incorrect or outdated.

Print this article Edit this article

Plotting in Mathematica


Basic Plotting

With the Plot command, you can plot one function or several functions. First, lets consider an example of plotting a single function. Take for example the equation, x3. To plot a single function, the Plot command takes the following form:

For the equation x3 with the boundary conditions, -10 < x < 10, you enter the Plot command as follows:

When you hit the shift and return key at the same time a graph of this function will appear.

Next, consider the two equations x2 and x3 over the boundary conditions, 0 < x < 5. The Plot command in the case of several functions takes the general form:

In the case of our two functions, the Plot command becomes:

When you hit the shift and return key at the same time a graph of the two functions will appear.


Contour Plotting

Contour plotting is frequently done in the sciences. For example, in the field of Atmospheric Sciences contour plotting is done on weather maps to show constant lines of pressure, temperature, wind direction, etc. MATHEMATICA can take functions and contour. To contour, you use the ContourPlot command which takes the general form:

    ContourPlot[function,{variable,xmin,xmax},{variable,ymin,ymax}]

For an equation X2+y2 where the boundary conditions are, -2 < x < 2 and -2 < y <2, the ContourPlot command takes the form:

    ContourPlot[x^2+y^2,{x,-2,2},{y,-2,2}]

When you hit the shift and return keys at the same time a contoured graph should appear.


Density Plotting

A density plot shows the values of your function at a regular array of points. Lighter regions on a density are higher. To do a density plot, you use the DensityPlot command which has the general form:

    DensityPlot[function,{variable,xmin,xmax},{variable,ymin,ymax}]

Consider the equation x2y3 with the boundary conditions, -3 < x < 3 and -3 < y < 3. The DensityPlot command will take the form:

    DensityPlot[x^2*y^2,{x,-3,3},{y,-3,3}]

When you hit the shift and return key at the same time a density plot will appear.


3-D Plotting

3-D plotting can help in visualizing physical problems. To do a 3-D plot, you use the Plot3D command which has the general form:

    Plot3D[function,{variable,xmin,xmax},{variable,ymin,ymax}]

Consider the equation Sin(xy) at the boundary conditions, 0 < x < 3 and 0 < y < 3. The Plot3D command will take the form:

    Plot3D[Sin[xy],{x,0,3},{y,0,3}]

When you hit the shift and return key at the same time a 3-D plot will appear.

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: Mar 7, 2007 11:48 am US/Eastern by admin
JumpURL: