Documentation Center

  • Trial Software
  • Product Updates

contourcmap

Contour colormap and colorbar for current axes

Syntax

contourcmap(cmapstr)
contourcmap(cmapstr,cdelta)
contourcmap(...,Name,Value)
h = contourcmap(...)

Description

contourcmap(cmapstr) updates the figure's colormap for the current axes with the colormap specified by cmapstr. If the axes contains Mapping Toolbox™ contour objects, the resultant colormap contains the same number of colors as the original colormap. Otherwise, the resultant colormap contains ten colors.

contourcmap(cmapstr,cdelta) updates the figure's colormap with colors varying according to cdelta. If the axes contains Mapping Toolbox contour objects, the value of cdelta is ignored.

contourcmap(...,Name,Value) allows you to add a colorbar and control the colorbar's properties. Parameter names can be abbreviated and are case-insensitive.

h = contourcmap(...) returns a handle to the colorbar axes.

Input Arguments

cmapstr

A string that specifies a colormap. Valid entries for cmapstr include 'pink', 'hsv', 'jet', or the name of any similar MATLAB® colormap function.

cdelta

A scalar or vector. If cdelta is a scalar, it represents a step size, and colors are generated at multiples of cdelta. If cdelta is a vector of evenly spaced values, colors are generated at those values; otherwise an error is issued.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Colorbar'

String with values 'on' or 'off' specifying whether a colorbar is present, 'on', or absent from the axes, 'off'.

Default: 'off'

'Location'

String specifying the location of the colorbar. Permissible values are 'vertical', 'horizontal', or 'none'.

Default: 'vertical'

'ColorAlignment'

String specifying the alignment of the labels in the colorbar. Permissible values are 'center', where the labels are centered on the color bands, or 'ends', where the labels are centered on the color breaks. If the axes contains Mapping Toolbox contour objects, the ColorAlignment will be set automatically to 'center' for contour lines and 'ends' for filled contours, and cannot be modified.

'SourceObject'

Handle of the graphics object which is used to determine the color limits for the colormap. The SourceObject value is the handle of a currently displayed object.

Default: gca

'TitleString'

String specifying the title of the colorbar axes.

'XLabelString'

String specifying the X label of the colorbar axes.

'YLabelString'

String specifying the Y label of the colorbar axes.

'ZLabelString'

String specifying the Z label of the colorbar axes. In addition, properties and values that can be applied to the title and labels of the colorbar axes are valid.

Output Arguments

h

A handle to the colorbar axes.

Examples

Display a world map with a colormap representing contour intervals in meters:

load topo
R = georasterref('RasterSize', size(topo), ...
   'Latlim', [-90 90], 'Lonlim', [0 360]);
figure('Color','white')
worldmap(topo, R)
contourfm(topo, R);
contourcmap('jet', 'Colorbar', 'on', ...
   'Location', 'horizontal', ...
   'TitleString', 'Contour Intervals in Meters');

Display a world map with a colormap in which colors vary at a step size of 2000:

load topo
load coast
R = georasterref('RasterSize', size(topo), ...
   'Latlim', [-90 90], 'Lonlim', [0 360]);
figure('Color','white')
worldmap(topo, R)
geoshow(topo, R, 'DisplayType', 'texturemap');
contourcmap('summer', 2000, 'Colorbar', 'on', ...
   'Location', 'horizontal', ...
   'TitleString', 'Contour Intervals in Meters');
geoshow(lat, long, 'Color', 'black')

See Also

| | | | | |

Was this topic helpful?