Main Content

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 properties of the colorbar. Parameter names can be abbreviated and are case-insensitive.

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

Input Arguments

cmapstr

A character vector 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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'Colorbar'

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

Default: 'off'

'Location'

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

Default: 'vertical'

'ColorAlignment'

Character vector 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'

Title of the colorbar axes, specified as a character vector.

'XLabelString'

X label of the colorbar axes, specified as a character vector.

'YLabelString'

Y label of the colorbar axes, specified as a character vector.

'ZLabelString'

Z label of the colorbar axes, specified as a character vector. 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

collapse all

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

First, load elevation raster data and a geographic cells reference object.

load topo60c

Create a map axes object with limits appropriate for the data. Display the elevation data using a filled contour plot. Then, update the colormap and add a labeled colorbar.

worldmap(topo60c,topo60cR)
contourfm(topo60c,topo60cR)
contourcmap('jet','Colorbar','on', ...
   'Location','horizontal', ...
   'TitleString','Contour Intervals in Meters');

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

First, load elevation raster data and a geographic cells reference object. Then, load coastline coordinates.

load topo60c
load coastlines

Create a map axes object with limits appropriate for the data. Display the elevation and coastline data.

worldmap(topo60c,topo60cR)
geoshow(topo60c,topo60cR,'DisplayType','texturemap')
geoshow(coastlat,coastlon,'Color','k')

Update the colormap and add a labeled colorbar. Specify the step size as the second argument.

contourcmap('summer',2000,'Colorbar','on', ...
   'Location','horizontal', ...
   'TitleString','Contour Intervals in Meters')

Introduced before R2006a