Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

demcmap

Colormaps appropriate to terrain elevation data

Syntax

demcmap(Z)
demcmap(Z,ncolors)
demcmap(Z,ncolors,cmapsea,cmapland)
demcmap('inc',Z,deltaz)
demcmap('inc',Z,deltaz,cmapsea,cmapland)
[cmap,climits] = demcmap(___)

Description

example

demcmap(Z) sets the colormap and color axis limits based on the elevation data limits derived from input argumentZ.

  • 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.

demcmap(Z,ncolors) creates a colormap of length ncolors.

example

demcmap(Z,ncolors,cmapsea,cmapland) assigns cmapsea and cmapland to elevations below and above sea level respectively.

demcmap('inc',Z,deltaz) chooses number of colors and color axis limits such that each color approximately represents the increment of elevation deltaz.

  • The literal 'inc' signals demcmap that the first argument after Z will be deltaz.

example

demcmap('inc',Z,deltaz,cmapsea,cmapland)assigns cmapsea and cmapland to elevations below and above sea level respectively.

[cmap,climits] = demcmap(___) returns colormap cmap and color axis limit climits, using any of the above syntaxes, but does not apply them to figure or axes properties.

  • Even if only one output argument is specified, no change occurs to figure or axes properties.

Examples

collapse all

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, cmapssea; cmapland , 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 of 64. 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;

The following demcmap example controls the color quantization by choosing an optimal number of colors such that each color represents an elevation increment of approximately 2000 .

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

Input Arguments

collapse all

Terrain elevation limits specified as a vector or matrix. If Z is a 2 element vector, then it specifies the minimum and maximum limits of terrain elevation data; ordering is not important. If Z is 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.

Data Types: single | double | int8 | int32 | uint8 | uint16 | uint32

Number of colors in the colormap specified as a scalar. It defines the number of rows m in the mx3 RGB matrix of the figure colormap.

Data Types: double

  • 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.

  • cmapsea and cmapland replace the default colormap. The default colormap for land or sea can be retained by providing an empty matrix in place of either colormap matrix.

That part of the figure colormap assigned to negative elevations is derived from cmapssea; cmapland plays a similar role for positive elevations.

Data Types: double

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 deltaz increment in elevation.

Data Types: double

Output Arguments

collapse all

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.

Data Types: double

Color axis limits returned as a vector. climits may differ somewhat from those derived from input argument Z due 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.

Data Types: double

Algorithms

If the elevation grid data contains both positive and negative values, then the computed colormap, cmap, has a “sea” partition of length nsea and "land" partition of length nland. The sum of nsea and nland equals the total number of entries in the computed colormap. The actual values of nsea and nland depend 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 ncolors. The sea and land partitions of the figure colormap are populated with colors interpolated from the basis RGB colormaps, cmapsea and cmapland. 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.

Introduced before R2006a

Was this topic helpful?