Label map contour plot
clabelm( labels the current contour plot
by adding upright text next to each contour line. The function randomly selects the
positions of the labels. This syntax displays plus symbols (
+) on the
contour lines next to the labels.
clabelm( labels the locations you
select with the mouse. Click the mouse or press the space bar to label the contour closest
to the center of the cursor. To finish labeling, while the cursor is within the figure,
labels as text objects and the plus symbols (
tl = clabelm(___)
+) as line objects, using
any combination of input arguments from the previous syntaxes in this group.
specifies the spacing between labels on the same contour line.
Add Labels to Contour Plot
Create a contour plot from sample map data. Obtain the contour matrix
C and the contour patch
h. Then, label the contour plot.
Z = peaks; R = georefcells([-0.1 0],[0 0.1],size(Z)); axesm miller [C,h] = contourm(Z,R); clabelm(C,h)
Label Specific Contour Levels
Create a contour plot using geoid heights from the Earth Gravitational Model of 1996 (EGM96). Label only the contours with contour levels
[N,R] = egm96geoid; worldmap(N,R) plabel off mlabel off [C,h] = contourm(N,R,-100:50:100); clabelm(C,h,[-100 50])
Set Contour Label Properties
Create an elevation map for a region surrounding the Korean peninsula.
load korea5c worldmap(korea5c,korea5cR) geoshow(korea5c,korea5cR,"DisplayType","texturemap") demcmap(korea5c)
Create a contour plot using geoid heights from the Earth Gravitational Model of 1996 (EGM96).
N = egm96geoid(korea5cR); [C,h] = contourm(N,korea5cR,-100:5:100,"k");
Label the contours and return the text objects. Change the text color and the edge color by setting properties of the text objects.
t = clabelm(C,h); set(t,"Color","r") set(t,"EdgeColor","k")
C — Contour matrix
Contour matrix, specified as a two-row matrix returned by the
contour3m function. This argument contains the data that defines
the contour lines. The first row of the matrix contains longitude data and the second
row of the matrix contains latitude data.
If you pass the contour object
h to the
clabelm function, then you can replace this argument with
. For example, use
h — Contour patches
Contour patches, specified as a
Group object returned by the
levels — Contour levels
Contour levels, specified as a row or column vector of individual values.
spacing — Label spacing
144 (default) | scalar
Label spacing along the contour lines, specified as a scalar value in points, where one point is 1/72 inch. Use this property to control the number of contour labels along the contour lines. Smaller values produce more labels.
If the length of a contour line is less than
spacing, then the
function displays one label on the line.
t — Text objects
Text objects, returned as a vector. The
UserData properties of
the text objects contain the contour values displayed.
tl — Text and line objects
Text and line objects, returned as a vector. The
properties of the text objects contain the contour values displayed. The line objects
correspond to the plus symbols (
Introduced before R2006a