clegendm

Add legend labels to map contour display

Syntax

clegendm(cs,h)
clegendm(cs,h,loc)
clegendm(...,unitstr)
clegendm(...,strings)
h = clegendm(...)

Description

clegendm(cs,h) adds a legend specifying the contour line heights to the current map contour plot.

clegendm(cs,h,loc) places the legend in the specified location.

clegendm(...,unitstr) appends unitstr to each entry in the legend.

clegendm(...,strings) uses the strings specified in strings to label the legend. strings must have the same number of entries as the line children of h.

h = clegendm(...) returns the handle to the legend object created.

Input Arguments

cs

Contour matrix output from contourm, contour3m, or contourfm

h

Object handle output from contourm, contour3m, or contourfm

loc

Any of the following integers, with the indicated placement:

IntegerPlacement

0

Automatic placement (default)

1

Upper right corner

2

Upper left corner

3

Lower left corner

4

Lower right corner

-1

To the right of the plot

unitstr

Character string appended to each entry in the legend

strings

Cell array of strings used to label the legend

Output Arguments

h

Handle to the legend object

Examples

Create a legend in the lower right-hand corner with a unit string indicating that the contour elevations are in meters:

load topo
R = georasterref('RasterSize', size(topo), ...
   'Latlim', [-90 90], 'Lonlim', [0 360]);
figure('Color','w'); worldmap('world')
[c,h] = contourm(topo, R, -6000:1500:6000);
clegendm(c,h,4,' m')

Was this topic helpful?