two-dimensional density plotting
densityplot(expr1, x=a..b, y=c..d)
densityplot(f, a..b, c..d)
function (or set of functions) to be plotted
expression or set of expressions in x and y
real constants or procedures defining the bounds of the second dimension (for a transformed problem)
The densityplot function produces a 2-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 49 by 49 grid is used; thus 2401 points are generated, and 2401 colored cells are displayed.
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.
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.
The command with(plots,densityplot) allows the use of the abbreviated form of this command.
A plot where scaling is really relevant. This is the command to create the plot from the Plotting Guide.
Adjusting the contrast and scaling to taste:
Use of a specified range:
Use of pure max and min (no auto-detection):
Using 'restricttoranges' produces a plot over 0..5 x 0..5 exactly:
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;
Download Help Document
What kind of issue would you like to report? (Optional)