Density plot appearance and behavior
expand all in page
DensityPlot
properties control the appearance and behavior of a DensityPlot
object. By changing property values, you can modify certain aspects of the density plot. Use dot notation to query and set properties.
dp = geodensityplot(1:10,1:10);f = dp.FaceColor;dp.FaceColor = "red";
Create a density plot in geographic coordinates by using the geodensityplot function.
Density
expand all
Radius
— Radius of influence, in meters
numeric scalar
Radius of influence on the density calculation, in meters, specified as a numeric scalar.
RadiusMode
— Control how Radius
is set
'auto'
(default) | 'manual'
Control how the Radius
property is set, specified as one of these values:
'auto'
— MATLAB® controls the value of theRadius
property.'manual'
— You manually control the value of theRadius
property. When you set theRadius
property, MATLAB sets this property to'manual'
.
WeightData
— Weights assigned to data
[]
(default) | numeric scalar | numeric vector
Weights assigned to data, specified as an empty array, a numeric scalar, or a numeric vector. If you specify a numeric vector, the length of the vector must match the lengths of LatitudeData
and LongitudeData
.
The WeightData
property typically contains additional data that is related to the location data in LatitudeData
and LongitudeData
.
WeightDataSource
— Variable linked to WeightData
''
(default) | character vector | string scalar
Variable linked to WeightData
, specified as a character vector or string scalar containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate the WeightData
.
By default, there is no linked variable, so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the WeightData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning. The geodensityplot
does not render the graph until you have changed all data source properties to appropriate values.
Color and Transparency
expand all
FaceAlpha
— Face transparency
'interp'
(default) | scalar in range [0, 1]
Face transparency, specified as one of these values:
'interp'
— Use interpolated transparency based on the density values.Scalar in the range [0, 1] — Use uniform transparency across all the faces. A value of
1
is opaque and a value of0
is completely transparent. Values between0
and1
are semitransparent.
The appearance of the density plot depends on both the FaceAlpha
and FaceColor
properties. This table shows how different combinations of FaceAlpha
and FaceColor
affect the appearance of the plot.
Values of FaceColor and FaceAlpha | Effect | Sample Density Plot |
---|---|---|
| The density plot uses one color and conveys density by varying the transparency. | |
| The density plot conveys density by varying the transparency and the color. | |
| The density plot uses one transparency value and conveys density by varying the color. | |
For more information about controlling the transparency of a density plot, see Adjust Transparency of Geographic Density Plots.
FaceColor
— Face color
[0 0 0]
(default) | 'interp'
| RGB triplet | hexadecimal color code | color name | short name
Face color, specified as one of these options:
'interp'
— Use interpolated coloring based on the density values. MATLAB chooses colors from the colormap of the parent axes. When you choose this option, the appearance of the density plot also depends on the value of theFaceAlpha
property. For more information, see the FaceAlpha property.An RGB triplet, a hexadecimal color code, a color name, or a short name — Apply one color to the density plot. When you choose this option, the value of
FaceAlpha
must be"interp"
.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
; for example,[0.4 0.6 0.7]
.A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Thus, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan" | "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
FaceColorMode
— Control how FaceColor
is set
"auto"
(default) | "manual"
Control how the FaceColor
property is set, specified as one of these values:
"auto"
— MATLAB controls the value of theFaceColor
property by using theSeriesIndex
property of theDensityPlot
object and theColorOrder
property of the axes."manual"
— You set the value of theFaceColor
property directly, or indirectly as a function argument when you create theDensityPlot
object.
If you change the value of the FaceColor
property manually, MATLAB changes the value of the FaceColorMode
property to "manual"
.
SeriesIndex
— Series index
positive whole number | "none"
Series index, specified as a positive whole number or "none"
. This property is useful for reassigning the face colors of DensityPlot
objects so that they match the colors of other objects.
By default, the value of the SeriesIndex
property is a number that corresponds to its order of creation, starting at 1
. MATLAB uses the number to calculate an index for assigning the face color when you call plotting functions. The index refers to the rows of the array stored in the ColorOrder
property of the axes. Any objects in the axes that have the same SeriesIndex
number will have the same color.
A SeriesIndex
value of "none"
corresponds to a neutral color that does not participate in the indexing scheme.
How Manual Color Assignment Overrides SeriesIndex
Behavior
To manually control fill color, set the FaceColor
property of the DensityPlot
object to a color value, such as a color name or RGB triplet.
When you manually set the fill color of an object, MATLAB disables automatic color selection for that object and allows your color to persist, regardless of the value of the SeriesIndex
property. The FaceColorMode
property indicates whether the colors have been set manually (by you) or automatically. A value of "manual"
indicates manual selection, and a value of "auto"
indicates automatic selection.
To enable automatic selection again, set the SeriesIndex
property to a positive whole number, and set the FaceColorMode
property to "auto"
.
In some cases, MATLAB sets the SeriesIndex
value to 0
, which also disables automatic color selection.
Geographic Coordinate Data
expand all
LatitudeData
— Latitude coordinates in degrees
numeric vector with elements in range [–90, 90] | []
Latitude coordinates in degrees, specified as a numeric vector with elements in the range [–90, 90] or as an empty ([]
) array. The vector can contain NaN
values. The sizes of LatitudeData
and LongitudeData
must match.
Data Types: single
| double
LatitudeDataSource
— Variable linked to LatitudeData
''
(default) | character vector | string scalar
Variable linked to LatitudeData
, specified as a character vector or string scalar containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate the LatitudeData
.
By default, there is no linked variable, so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the LatitudeData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning. The geodensityplot
does not render the graph until you have changed all data source properties to appropriate values.
LongitudeData
— Longitude coordinates in degrees
numeric vector | []
Longitude coordinates in degrees, specified as a numeric vector or an empty ([]
) array. The vector can contain NaN
values. The sizes of LongitudeData
and LatitudeData
must match.
The span of the longitude values must be less than or equal to 360 degrees.
Data Types: single
| double
LongitudeDataSource
— Variable linked to LongitudeData
''
(default) | character vector | string scalar
Variable linked to LongitudeData
, specified as a character vector, or string scalar containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate the LongitudeData
.
By default, there is no linked variable, so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the LongitudeData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning. The geodensityplot
does not render the graph until you have changed all data source properties to appropriate values.
Legend
expand all
Interactivity
expand all
Callbacks
expand all
Callback Execution Control
expand all
Parent/Child
expand all
Parent
— Parent
GeographicAxes
object
Parent, specified as a GeographicAxes
object.
Identifiers
expand all
Type
— Type of graphics object
'densityplot'
(default)
This property is read-only.
Type of graphics object, returned as 'densityplot'
. Use this property to find all objects of a given type within a plotting hierarchy, for example, searching for the type using findobj.
Version History
Introduced in R2018b
expand all
R2023b: Opt out of automatic color selection with SeriesIndex="none"
Opt out of automatic color selection for DensityPlot
objects by setting the SeriesIndex
property to "none"
. When you specify "none"
, the DensityPlot
object has a neutral color.
To enable automatic color selection again, set the SeriesIndex
property to a positive whole number.
R2020a: Control automatic color selection with the SeriesIndex
property
Control how DensityPlot
objects vary in color by setting the SeriesIndex
property. This property is useful when you want to match the colors of different objects in the axes.
R2020a: UIContextMenu
property is not recommended
Starting in R2020a, using the UIContextMenu
property to assign a context menu to a graphics object or UI component is not recommended. Use the ContextMenu
property instead. The property values are the same.
There are no plans to remove support for the UIContextMenu
property at this time. However, the UIContextMenu
property no longer appears in the list returned by calling the get
function on a graphics object or UI component.
See Also
Functions
- geodensityplot
Topics
- Visualize Density Using Geographic Density Plots
- Adjust Transparency of Geographic Density Plots
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Contact your local office