Density and Contour Plots
|make a density plot of f|
| ||make a contour plot of f as a function of x and y|
Density and contour plots.
This gives a density plot of sin (x) sin (y)
. Lighter regions show higher values of the function.
Some options for DensityPlot.
You can include a mesh like this.
In a density plot, the color of each point represents the value at that point of the function being plotted. By default, the color ranges from black to white through intermediate shades of blue as the value of the function increases. In general, however, you can specify other "color maps" for the relation between the value at a point and its color. The option ColorFunction
allows you to specify a function which is applied to the function value to find the color at any point. The color function may return any Mathematica
color directive, such as GrayLevel
. A common setting to use is ColorFunction->Hue
This uses different hues to represent different values.
A significant resource for customized color functions is the ColorData
provides many customized sets of colors which can be used directly by ColorFunction
This shows a list of the gradients which can be accessed using ColorData
is identical to the one above, but uses the "SolarColors"
This gives a contour plot of the function.
A contour plot gives you essentially a "topographic map" of a function. The contours join points on the surface that have the same height. The default is to have contours corresponding to a sequence of equally spaced z
values. Contour plots produced by Mathematica
are by default shaded, in such a way that regions with higher z
values are lighter.
Some options for ContourPlot.
This shows the plot with no shading.
This cycles the colors used for contour regions between light red and light purple.
use an adaptive algorithm that subdivides parts of the plot region to obtain more sample points for a smoother representation of the function you are plotting. Because the number of sample points is always finite, however, it is possible that features of your function will sometimes be missed. When necessary, you can increase the number of sample points by increasing the values of the PlotPoints
One point to notice is that whereas a curve generated by Plot
may be inaccurate if your function varies too quickly in a particular region, the shape of contours generated by ContourPlot
can be inaccurate if your function varies too slowly. A rapidly varying function gives a regular pattern of contours, but a function that is almost flat can give irregular contours. You can typically overcome this by increasing the value of PlotPoints