This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Plotting Lists of Data

Mathematica can be used to make plots of functions. You give Mathematica a function, and it builds up a curve or surface by evaluating the function at many different points.
Here we describe how you can make plots from lists of data, instead of functions. ("Importing and Exporting Data" discusses how to read data from external files and programs.) The Mathematica commands for plotting lists of data are direct analogs of the ones for plotting functions.
ListPlot[{y1,y2,...}]plot y1, y2, ... at x values 1, 2, ...
ListPlot[{{x1,y1},{x2,y2},...}]plot points (x1, y1), ...
ListLinePlot[list]join the points with lines
ListPlot3D[{{z11,z12,...},{z21,z22,...},...}]
make a three-dimensional plot of the array of heights zyx
ListPlot3D[{{x1,y1,z1},{x2,y2,z2},...}]
make a three-dimensional plot with heights zi at positions {xi, yi}
ListContourPlot[array]make a contour plot
ListDensityPlot[array]make a density plot

Functions for plotting lists of data.

Here is a list of values.
In[1]:=
Click for copyable input
Out[1]=
This plots the values.
In[2]:=
Click for copyable input
Out[2]=
This joins the points with lines.
In[3]:=
Click for copyable input
Out[3]=
When plotting multiple data sets, Mathematica chooses a different color for each data set automatically.
In[4]:=
Click for copyable input
Out[4]=
This gives a list of x, y pairs.
In[5]:=
Click for copyable input
Out[5]=
This plots the points.
In[6]:=
Click for copyable input
Out[6]=
This gives a rectangular array of values. The array is quite large, so we end the input with a semicolon to stop the result from being printed out.
In[7]:=
Click for copyable input
This makes a three-dimensional plot of the array of values.
In[8]:=
Click for copyable input
Out[8]=
This gives a density plot of the array of values.
In[9]:=
Click for copyable input
Out[9]=