Colormaps appropriate to terrain elevation data
demcmap( sets the
colormap and color axis limits based on the elevation data limits
derived from input argument
The default colormap assigns shades of green and brown for positive elevations, and various shades of blue for negative elevation values below sea level.
The number of colors assigned to land and to sea are in proportion to the ranges in terrain elevation and bathymetric depth and total 64 by default. The color axis limits are computed such that the interface between land and sea maps to the zero elevation contour.
The colormap is applied to the current figure and the color axis limits are applied to the current axes.
Explicitly determine maximum and minimum values of elevation data matrix
load topo axesm hatano meshm(topo,topolegend) zlimits = [min(topo(:)) max(topo(:))]; demcmap(zlimits); colorbar;
Custom RGB colormaps,
of differing lengths are used to populate figure colormap by interpolation.
The colors in each colormap map to the land and sea regions of the
map. Fewer colors have been specified in total than the default number
demcmap determines maximum and minimum elevation
data limits internally as shown in the below example when the first
argument is the elevation data grid.
load topo % grid of elevation data axesm hatano meshm(topo,topolegend) cmapsea = [.8 0 .8; 0 0 .8]; cmapland = [.7 0 0; .8 .8 0; 1 1 .8 ]; demcmap(topo,32,cmapsea,cmapland) colorbar;
controls the color quantization by choosing an optimal number of colors
such that each color represents an elevation increment of approximately
load topo R = georasterref('RasterSize',size(topo),'Latlim',[-90 90],'Lonlim',[0 360]); figure('Color','white') worldmap('world') geoshow(topo, R, 'DisplayType', 'texturemap') demcmap('inc',[max(topo(:)) min(topo(:))],2000); colorbar
Z— Terrain elevation limits
Terrain elevation limits specified as a vector or matrix. If
a 2 element vector, then it specifies the minimum and maximum limits
of terrain elevation data; ordering is not important. If
a matrix, then it specifies an elevation grid in which positive and
negative values represent points above and below sea level respectively.
The above two syntaxes for
demcmap are identical
in their effect on the figure colormap and axes properties.
ncolors— Number of colors in colormap
Number of colors in the colormap specified as a scalar. It defines
the number of rows
m in the mx3 RGB matrix of the
cmapsea,cmapland— RGB colormap matrices
RGB colormaps specified as mx3 arrays containing any number of rows. The two colormaps need not be equal in length. They serve as the basis set for populating the figure colormap by interpolation.
the default colormap. The default colormap for land or sea can be
retained by providing an empty matrix in place of either colormap
That part of the figure colormap assigned to negative elevations
is derived from
a similar role for positive elevations.
deltaz— Increment of elevation
The increment of elevation specified as a scalar. The color
quantization of the default or user supplied colormap is adjusted
such that each discrete color approximately represents a
cmap— RGB colormap
RGB colormap returned as a matrix constructed for the figure
colormap. Supply output arguments when you want to obtain the colormap
and color axis limits without applying them automatically to the figure
or axes properties. These properties remain unchanged even if only
one output (
cmap) is specified.
climits— Color axis limits
Color axis limits returned as a vector.
differ somewhat from those derived from input argument
to the quantization which results from fitting a limited number of
colors over the range limit of the elevation data.
Supply output arguments when you want to obtain the colormap and color axis limits without applying them automatically to the figure or axes.
If the elevation grid data contains both positive and negative
values, then the computed colormap,
cmap, has a
“sea” partition of length
"land" partition of length
nland. The sum of
the total number of entries in the computed colormap. The actual
upon the number of entries and the relative range of the negative
and positive limits of the elevation data. The sea partition consists
of rows 1 through
nsea, and the land partition
consists of rows
nsea + 1 through
The sea and land partitions of the figure colormap are populated with
colors interpolated from the basis RGB colormaps,
In the figure below, the sea and land 3x3 RGB colormaps shown are
the default colors used by
demcmap to populate
the figure colormap when no user specified colormaps are provided.
If the elevation grid data contains only positive or negative values, then the figure colormap is derived solely from the corresponding sea or land colormap.