densityplot - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : 2-D : densityplot

plots

  

densityplot

  

two-dimensional density plotting

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

densityplot(expr1, x=a..b, y=c..d)

densityplot(f, a..b, c..d)

Parameters

f

-

function (or set of functions) to be plotted

expr1

-

expression or set of expressions in x and y

a, b

-

real constants

c, d

-

real constants or procedures defining the bounds of the second dimension (for a transformed problem)

x, y

-

names

Description

• 

The densityplot function produces a two-dimensional plot of a function of 2 variables where color is used to provide information on the value of the function with respect to the two variables.

• 

In the first calling sequence, densityplot(expr1, x=a..b, y=c..d), the expression expr1 must be an expression in the names x and y. The first range a..b must evaluate to real constants, while the second range c..d must either evaluate to real constants, or must be single variable functions that, given the value x, provide the corresponding endpoint of the range for y as a real constant. They specify the range over which expr1 is plotted.

  

In the second calling sequence, densityplot(f, a..b, c..d), f must be a Maple procedure or operator that takes two arguments. Operator notation must be used, that is, the procedure name is given without parameters specified, and the ranges must be given simply in the form a..b and c..d, rather than as equations.

• 

Any additional arguments are interpreted as options which are specified as equations of the form option = value. For example, the option grid = [m, n] where m and n are positive integers specifies that the plot is to be constructed on an m by n grid at equally spaced points in the ranges a..b and c..d respectively. By default a 99 by 99 grid is used, double the value stored in the grid option of plots:-setoptions3d.

• 

The default coloring is SHADING, which produces a gray shading plot. Hue or RGB coloring can be specified via the colorstyle = t option (where t is one of HUE, RGB or SHADING). Additionally, specification of a color option modifies the behavior of the coloring for colorstyle = SHADING or RGB, but has no effect on Hue coloring. The colorscheme option as described on the plot/colorscheme help page can also be used to color density plots.

• 

There are three options for controlling the color scaling in a density plot: contrast, brightness, and the detailed option scaletorange. Note: Neither contrast nor brightness can be specified when scaletorange is specified because they adjust the same property: the color scaling range.

• 

The densityplot command auto-detects a scaling range that produces a visually pleasing contrast and brightness for the plot, but allows for fine tuning.

  

The contrast parameter defaults to 0.5, and controls the degree of variation based on values in the plot. Raising the contrast results in a plot that has a greater number of values at or closer to the ends of the color range chosen for the plot.

  

The brightness parameter also defaults to 0.5. A higher value produces a plot that is shifted towards the brighter end of the color range, while a lower value produces a plot that is shifted towards the darker end of the color range.

  

Note: Specification of contrast=0 restores the behavior of densityplot from Maple 10 and earlier, which is to simply use the minimum and maximum values of the function to determine the color scaling range of the density plot, avoiding the use of the built-in auto-detection.

• 

The contrast and brightness parameters work with the auto-detection for a suitable color range to use for the plot, while in contrast the scaletorange option overrides any auto-detection, and specifies the top and bottom end of the value range that corresponds to the color range for the plot. (Note: Values outside the range are pushed to the closest end of the range.)

  

For example, specifying scaletorange=−5..5 produces a density plot where function values <=5 are plotted at the lowest value of the color range, and function values >=5 are plotted at the highest value of the color range.

• 

The exact value of the color scaling range used for the plot is displayed if infolevel[densityplot] is set to 1 or greater. The minimum and maximum function values for the density plot are displayed if infolevel[densityplot] is set to 2 or greater.

• 

The restricttoranges parameter is used to restrict the density plot so that it is drawn with the edges exactly on the border of the specified ranges. Note that by default this option is false, and the cells are drawn around each point in the grid, resulting in a plot with 1/2 cell overlap at the borders of the plot.

• 

By default, density plots are displayed with a color bar indicating which colors correspond to which function values. This default behavior corresponds to the colorbar = true (or just colorbar) option  being passed. This display of the color bar can also be modified by using colorbar = list_of_options, as described in plot/colorbar. You can turn off the display of a color bar by passing the colorbar = false option. (You can also use the alternate spelling colourbar.) Turning off color bars affords slightly more space for the plot itself in the display.

• 

All other options are the same as those found for two-dimensional plots (see plot/options).

• 

The result of a call to densityplot is a PLOT data structure containing enough information to render the plot. The user may assign a PLOT value to a variable, save it in a file, then read it back in for redisplay. See plot/structure for more information.

Examples

withplots&colon;

densityplotsinx+y&comma;x=1..1&comma;y=1..1

densityplotbinomial&comma;0..5&comma;0..5&comma;style=surfacewireframe&comma;grid=10&comma;10

densityplotsinxy&comma;x=π..π&comma;y=π..π&comma;axes=boxed&comma;colormap=Plasma

densityplotxexpx2y2&comma;x=2..2&comma;y=2..2

densityplotxexpx2y2&comma;x=2..2&comma;y=2..2&comma;color=Blue

Turn off the default color bar display.

densityplotxexpx2y2&comma;x=2..2&comma;y=2..2&comma;color=Blue&comma;colorbar=false

densityplotxexpx2y2&comma;x=2..2&comma;y=2..2&comma;colorscheme=Blue&comma;Green&comma;Orange

densityplotx3&comma;x=1..1&comma;y=x21..1x2

densityplotx&comma;yx&comma;0..1&comma;0..x1x

A plot where scaling is really relevant.  This is the command to create the plot from the Plotting Guide.

densityplotxx2y2x2+y22&comma;x=0.1..0.1&comma;y=0.1..0.1&comma;grid=128&comma;128&comma;color=Red

Adjusting the contrast and scaling to taste:

densityplotxx2y2x2+y22&comma;x=0.1..0.1&comma;y=0.1..0.1&comma;grid=128&comma;128&comma;brightness=0.7&comma;contrast=0.7

Use of a specified range:

densityplotxx2y2x2+y22&comma;x=0.1..0.1&comma;y=0.1..0.1&comma;grid=128&comma;128&comma;scaletorange=0..2

Use of pure max and min (no auto-detection):

densityplotxx2y2x2+y22&comma;x=0.1..0.1&comma;y=0.1..0.1&comma;grid=128&comma;128&comma;contrast=0

Using 'restricttoranges' produces a plot over 0..5 x 0..5 exactly:

densityplotsinx2+y2&comma;x=0..5&comma;y=0..5&comma;restricttoranges=true

Plotting a Julia Set.

JuliaSet := proc(a, b)
 local z1, z2, z1s, z2s, m;
 (z1, z2) := (a, b):
 z1s := z1^2:
 z2s := z2^2;
 for m to 30 while z1s+z2s < 4 do
   (z1, z2) := (z1s-z2s, 2*z1*z2) + (0, 0.75);
   z1s := z1^2;
   z2s := z2^2;
 end do;
 m;
end proc:   

densityplotJuliaSet&comma;1.5..1.5&comma;1.4..1.4&comma;colorscheme=reverse turbo&comma;grid=150&comma;150&comma;axes=none

Compatibility

• 

The colorbar option was introduced in Maple 2023.

• 

For more information on Maple 2023 changes, see Updates in Maple 2023.

• 

The plots[densityplot] command was updated in Maple 2024.

• 

The colorbar option was updated in Maple 2024.

See Also

plot

plot/colorscheme

plot/options

plot3d/structure

plots

Statistics:-DensityPlot