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:

Create a contouring overlay mesh:

Use a multi-panel layout to show multiple functions at the same time:

Scope  (19)

Sampling  (11)

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:

Plot over an infinite domain:

Presentation  (8)

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:

Show multiple functions as densities in separate panels:

Use a column instead of a row:

Options  (89)

AspectRatio  (4)

By default, DensityPlot uses the same width and height:

Use a numerical value to specify the height to width ratio:

AspectRatioAutomatic determines the ratio from the plot ranges:

AspectRatioFull adjusts the height and width to tightly fit inside other constructs:

Axes  (4)

By default, DensityPlot uses a frame instead of axes:

Use axes instead of a frame:

Use AxesOrigin to specify where the axes intersect:

Turn each axis on individually:

AxesLabel  (4)

No axes labels are drawn by default:

Place a label on the axis:

Specify axes labels:

Use labels based on variables specified in DensityPlot:

AxesOrigin  (2)

The position of the axes is determined automatically:

Specify an explicit origin for the axes:

AxesStyle  (4)

Change the style for the axes:

Specify the style of each axis:

Use different styles for the ticks and the axes:

Use different styles for the labels and the axes:

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:

ImageSize  (7)

Use named sizes such as Tiny, Small, Medium and Large:

Specify the width of the plot:

Specify the height of the plot:

Allow the width and height to be up to a certain size:

Specify the width and height for a graphic, padding with space if necessary:

Setting AspectRatioFull will fill the available space:

Use maximum sizes for the width and height:

Use ImageSizeFull to fill the available space in an object:

Specify the image size as a fraction of the available space:

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:

PlotLayout  (3)

Place each density in a separate panel using shared axes:

Use a row instead of a column:

Use multiple columns or rows:

Prefer full columns or rows:

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 2021).

Text

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

CMS

Wolfram Language. 1988. "DensityPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. 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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_densityplot, organization={Wolfram Research}, title={DensityPlot}, year={2021}, url={https://reference.wolfram.com/language/ref/DensityPlot.html}, note=[Accessed: 21-December-2024 ]}