DensityPlot

DensityPlot[f,{x,xmin,xmax},{y,ymin,ymax}]

makes a density plot of f as a function of x and y.

DensityPlot[f,{x,y}reg]

takes the variables {x,y} to be in the geometric region reg.

Details and Options

Examples

open allclose all

Basic Examples  (4)

Plot a function:

Use a different color scheme and legend:

Add an overlay mesh:

Create a contouring overlay mesh:

Scope  (17)

Sampling  (10)

More points are sampled where the function changes quickly:

The plot range is selected automatically:

Areas where the function becomes nonreal are excluded:

The region is split when there are discontinuities in the function:

Use PlotPoints and MaxRecursion to control adaptive sampling:

Use PlotRange to focus in on areas of interest:

Use Exclusions to remove curves or split the resulting surface:

Use RegionFunction to restrict the surface to a region given by inequalities:

The domain may be specified by a region:

The domain may be specified by a MeshRegion:

Presentation  (7)

Add labels:

Color the surface by height:

Add a legend:

Provide an interactive Tooltip for a surface:

Style the overlay mesh:

Create a contouring overlay mesh:

Use a theme with simple ticks in a high-contrast color scheme:

Options  (70)

AspectRatio  (2)

Choose the ratio of height to width from the actual plot values:

Set the ratio to 1:

Axes  (1)

Draw both and axes:

AxesLabel  (2)

Use automatically determined axes labels:

Set axes labels explicitly:

AxesOrigin  (1)

Specify the axes origin at the point :

BoundaryStyle  (3)

Use a red boundary around the edges of the surface:

BoundaryStyle applies to regions cut by RegionFunction:

BoundaryStyle does not apply to cuts made by Exclusions:

Use ExclusionsStyle instead:

ClippingStyle  (4)

Show clipped regions like the rest of the surface:

Leave clipped regions empty:

Use pink to fill the clipped regions:

Use light red where the surface is clipped above and pink below:

ColorFunction  (5)

Color by scaled coordinate:

Specify gray-level intensity by scaled coordinate:

Named color gradients color in the direction:

Use brightness to correspond to height or density of a function:

Use the interpolation between two colors to indicate the height or density of a function:

ColorFunctionScaling  (1)

Get the natural range of values by setting ColorFunctionScaling to False:

EvaluationMonitor  (2)

Show where DensityPlot samples a function:

Count how many times is evaluated:

Exclusions  (6)

This uses automatic methods to compute exclusions:

Indicate that no exclusions should be computed:

Give exclusions as an equation:

Give multiple exclusion sets:

Use a condition with the exclusion equation:

Use both automatically computed and explicit exclusions:

ExclusionsStyle  (1)

Use a red boundary to indicate the excluded curves:

Frame  (2)

Draw no frame:

Draw frames on the bottom and the left edges only:

FrameLabel  (1)

Use the independent variable names as FrameLabel:

MaxRecursion  (1)

Refine the function where it changes quickly:

Mesh  (6)

Use no mesh:

Show the initial and final sampling mesh:

Use 5 mesh lines in each direction:

Use 3 mesh lines in the direction and 6 mesh lines in the direction:

Use mesh lines at specific values:

Use different styles for different mesh lines:

MeshFunctions  (3)

Use the value as the mesh function:

Use mesh lines in the and directions:

Use mesh lines corresponding to fixed distances from the origin:

MeshStyle  (2)

Use red mesh lines:

Use red mesh lines in the direction and dashed mesh lines in the direction:

PerformanceGoal  (2)

Generate a higher-quality plot:

Emphasize performance, possibly at the cost of quality:

PlotLegends  (4)

Show a legend for the heights:

PlotLegends automatically matches the color function:

Use Placed to change legend position:

Use BarLegend to change legend appearance:

PlotPoints  (2)

Use more initial points to get a smoother density:

Use 20 initial points in the direction and 5 in the direction:

PlotRange  (4)

Automatically compute the range:

Use all points to compute the range:

Show the surface over the full , range:

Automatically compute the , range:

Use an explicit range to emphasize features:

PlotTheme  (1)

Use a theme with detailed ticks and a legend:

Change the color function:

RegionFunction  (3)

Plot over an annulus region in and :

Regions do not have to be connected:

Use any logical combination of conditions:

ScalingFunctions  (9)

By default, plots have linear scales in each direction:

Use a log scale in the direction:

Use a linear scale in the direction that shows smaller numbers at the top:

Use a reciprocal scale in the direction:

Use different scales in the and directions:

Reverse the axis without changing the axis:

Use a scale defined by a function and its inverse:

Positions in Ticks and GridLines are automatically scaled:

PlotRange is automatically scaled:

WorkingPrecision  (2)

Evaluate functions using machine-precision arithmetic:

Evaluate functions using arbitrary-precision arithmetic:

Applications  (7)

Plot a sum of 5 sine waves in random directions:

This shows the solution to the heat equation in one dimension:

Plot a saddle surface; the mesh curves show where the function is zero:

The 1, 2, 3, and norms, with the iso-norm mesh lines at 1/2, 1, and 3/2:

Show argument variation for sin, cos, tan, and cot over the complex plane:

Show the different complex components for a function:

Transform a function to expose more features:

Properties & Relations  (9)

DensityPlot samples more points where it needs to:

Use ContourPlot to get segmented iso curves and contour regions:

Use ListDensityPlot for plotting continuous data:

Use Plot3D to get 3D surfaces:

Add a ColorFunction to get an overlay density:

ComplexPlot plots the phase of a function using color and shades by the magnitude:

Use ArrayPlot or MatrixPlot for discrete data:

Use Plot for univariate functions:

Use ParametricPlot for plane parametric curves and regions:

Use ContourPlot3D and RegionPlot3D for implicit surfaces and regions:

Possible Issues  (2)

With segmenting or piecewise color functions, the transition color borders may not be sharp:

Use ContourPlot for segmenting problems instead:

Color functions or densities that change quickly may show artifacts:

Use PlotPoints to increase the sampling density:

Neat Examples  (2)

Branch cuts for inverse trigonometric functions:

Real and imaginary part overlay mesh:

Wolfram Research (1988), DensityPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/DensityPlot.html (updated 2017).

Text

Wolfram Research (1988), DensityPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/DensityPlot.html (updated 2017).

BibTeX

@misc{reference.wolfram_2021_densityplot, author="Wolfram Research", title="{DensityPlot}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/DensityPlot.html}", note=[Accessed: 03-August-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_densityplot, organization={Wolfram Research}, title={DensityPlot}, year={2017}, url={https://reference.wolfram.com/language/ref/DensityPlot.html}, note=[Accessed: 03-August-2021 ]}

CMS

Wolfram Language. 1988. "DensityPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/DensityPlot.html.

APA

Wolfram Language. (1988). DensityPlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DensityPlot.html