Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

ListContourPlot


Usage Message:

ListContourPlot[array] generates a contour plot from an array of height values.

Attributes[ListContourPlot] = {Protected}

Options:

AspectRatio -> 1
Axes -> False
AxesLabel -> None
AxesOrigin -> Automatic
AxesStyle -> Automatic
Background -> Automatic
ColorFunction -> Automatic
ColorOutput -> Automatic
ContourLines -> True
Contours -> 10
ContourShading -> True
ContourSmoothing -> True
ContourStyle -> Automatic
DefaultColor -> Automatic
Epilog -> {}
Frame -> True
FrameLabel -> None
FrameStyle -> Automatic
FrameTicks -> Automatic
ImageSize -> Automatic
MeshRange -> Automatic
PlotLabel -> None
PlotRange -> Automatic
PlotRegion -> Automatic
Prolog -> {}
RotateLabel -> True
Ticks -> Automatic
DefaultFont :> $DefaultFont
DisplayFunction :> $DisplayFunction
FormatType :> $FormatType
TextStyle :> $TextStyle

Notes:

ListContourPlot constructs a ContourGraphics expression and generates an image using MeshRange option. Here is a typical example, which also shows a use of the FrameLabel option to put labels on the frame around the plot. Contour plots are drawn with a frame unless you include Frame -> False .
In[1]:= data = Table[y Cos[x], {y, 0, 1, .1}, {x, 0, 2 Pi, Pi/5}];

In[2]:= g = ListContourPlot[data, MeshRange -> {{0, 2 Pi}, {0, 1}},
                 FrameLabel -> {x, y}]        
        
Out[2]= -ContourGraphics-
The first row in the data corresponds to the bottom of the image, and the first column corresponds to the left side of the image.

If the data are not on a regular grid, the most general approach is to triangulate the data and use a contouring algorithm for triangulated data. The contouring algorithm invoked by ListContourPlot is designed for data on a regular grid. If the grid is not completely irregular, it is sometimes possible to get a useful plot using ListContourPlot by interpolating and resampling the data onto a regular grid, or by an appropriate mapping of the graphics expression. For notes about triangulation, see TriangularSurfacePlot , and the notes for
How do I generate a surface plot of irregularly spaced data?

Here is an example using a data set that consists of a list of x, y, z coordinates. To use ListContourPlot, it is necessary to construct from this list an array of z-values. This can almost always be achieved using a simple combination of functions such as Map , Partition , Sort , and Transpose . The required operations will depend on the details of the example.

In[3]:= data = {{-2,  0,1}, {-1,  0,1}, {0,  0,2}, {1,  0,2}, {2,  0,2},
                {-2, 50,1}, {-1, 50,2}, {0, 50,2}, {1, 50,2}, {2, 50,2},
                {-2,100,1}, {-1,100,1}, {0,100,1}, {1,100,1}, {2,100,2}};

In[4]:= zdata = Partition[Map[Last, data], 5]

Out[4]= {{1, 1, 2, 2, 2}, {1, 2, 2, 2, 2}, {1, 1, 1, 1, 2}}
The first plot below shows a contour plot of zdata displayed using ListContourPlot with the MeshRange , ContourShading , Contours , and FrameLabel options. The second plot shows the raw data together with the contour plot. The angular nature of the contours in these plots is a consequence of the small number of data points.
In[5]:= c = ListContourPlot[zdata,
                    MeshRange -> {{-2, 2}, {0, 100}},
                    ContourShading -> False,
                    Contours -> {1.1, 1.6, 1.7, 1.8},
                    FrameLabel -> {x, y}]                
Out[5]= -ContourGraphics-

In[6]:= tg = Graphics[Apply[Text[#3, {#1, #2}] &, Partition[data, 5], {2}]]

Out[6]= -Graphics-

In[7]:= Show[c, tg]
Out[7]= -Graphics-


Additional Online Documentation:

Mathematica 3.0
http://documents.wolfram.com/v3/RefGuide/ListContourPlot.html

Mathematica 4.0
http://documents.wolfram.com/v4/RefGuide/ListContourPlot.html




 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy