## 2.10.7 Density and Contour Plots

 DensityGraphics[array] density plot ContourGraphics[array] contour plot

Graphics objects that represent density and contour plots.

The functions DensityPlot and ContourPlot discussed in Section 1.9.5 work by creating ContourGraphics and DensityGraphics objects containing arrays of values.

Most of the options for density and contour plots are the same as those for ordinary two-dimensional plots. There are, however, a few additional options.

 option name default value ColorFunction Automatic how to assign colors to each cell ColorFunctionScaling True whether to scale values before applying a color function Mesh True whether to draw a mesh MeshStyle Automatic a style for the mesh

Additional options for density plots.

In a density plot, the color of each cell represents its value. By default, each cell is assigned a gray level, running from black to white as the value of the cell increases. In general, however, you can specify other "color maps" for the relation between the value of a cell and its color. The option ColorFunction allows you to specify a function which is applied to each cell value to find the color of the cell. With ColorFunctionScaling->True the cell values are scaled so as to run between 0 and 1 in a particular density plot; with ColorFunctionScaling->False no such scaling is performed. The function you give as the setting for ColorFunction may return any Mathematica color directive, such as GrayLevel, Hue or RGBColor. A common setting to use is ColorFunction -> Hue.

Here is a density plot with the default ColorFunction.
 In[1]:=  DensityPlot[Sin[x y], {x, -1, 1}, {y, -1, 1}]

 Out[1]=
This gives a density plot with a different "color map".
 In[2]:=  Show[%, ColorFunction -> (GrayLevel[#^3]&)]

 Out[2]=

 option name default value Contours 10 what contours to use ContourLines True whether to draw contour lines ContourStyle Automatic style to use for contour lines ContourShading True whether to shade regions in the plot ColorFunction Automatic how to assign colors to contour levels ColorFunctionScaling True whether to scale values before applying a color function

Options for contour plots.

In constructing a contour plot, the first issue is what contours to use. With the default setting Contours -> 10, Mathematica uses a sequence of 10 contour levels equally spaced between the minimum and maximum values defined by the PlotRange option.

 Contours -> n use a sequence of n equally spaced contours Contours -> {, , ... } use contours with values , , ...

Specifying contours.
This creates a contour plot with two contours.
 In[3]:=  ContourPlot[Sin[x y], {x, -1, 1}, {y, -1, 1}, Contours -> {-.5, .5}]

 Out[3]=

There are some slight subtleties associated with labeling density and contour plots. Both the Axes and Frame options from ordinary two-dimensional graphics can be used. But setting AxesOrigin -> Automatic keeps the axes outside the plot in both cases.

THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.