Main Content

contourcbar

Color bar for filled contour map display

Syntax

H = contourcbar(...)

Description

H = contourcbar(...) creates a color bar associated with a filled contour display created with contourfm, contourm, contour3m, or geoshow. It supports the same syntax and usage options as the function colorbar.

Examples

collapse all

Load elevation raster data and a geographic cells reference object.

load topo60c

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

worldmap('north america')
contourfm(topo60c,topo60cR,-7000:1000:3000)
caxis([-8000 4000])
contourcbar

Create a world map. Move the meridian labels to the bottom of the map and reduce the number of meridian labels.

figure
ax = worldmap('world');
setm(ax,'MLabelParallel',-90)
setm(ax,'MLabelLocation',90)

Get geoid heights and a geographic postings reference object from the EGM96 geoid model. Specify non-uniform levels in meters at which to contour the geoid. Then, display the geoid as a filled contour plot.

[N,R] = egm96geoid;
levels = [-70 -40 -20 -10 0 10 20 40 70];
geoshow(N,R,'DisplayType','contour',...
   'LevelList',levels,'Fill','on','LineColor','black')

Add a colorbar to the bottom of the figure. Add a label.

cb = contourcbar('peer',ax,'Location','southoutside');
cb.XLabel.String = 'Geoid Undulation in Meters';

Set the colormap limits using the caxis function. Then, apply a different colormap.

caxis([-110 90])
colormap(hsv)

Tips

  • If a peer axes is specified when calling contourcbar, it should be a map axes containing an object created using one of the Mapping Toolbox™ functions listed previously. Otherwise the current axes should contain such an object.

  • If a Mapping Toolbox contour object is present, then the color bar is filled with solid blocks of color which bound each other at the contour levels used in the plot. Thus, the contour levels bounding a fill polygon of a given color can be inferred graphically by inspecting the upper and lower limits of the corresponding block in the color bar. In the absence of a Mapping Toolbox contour object an ordinary color bar is created.

  • If multiple Mapping Toolbox contour objects are present in the same axes, then the levels used to divide the color bar into blocks will correspond to the first contour object that is found. This situation could occur when a larger data set is broken up into multiple grid tiles, for example, but as long the tiles all use the same contour level list, the color bar will correctly represent them all.

Introduced in R2011b