Navigation

Operators and Keywords

Function List:

C++ API

: clabel (c, h)
: clabel (c, h, v)
: clabel (c, h, "manual")
: clabel (c)
: clabel (…, prop, val, …)
: h = clabel (…)

Add labels to the contours of a contour plot.

The contour levels are specified by the contour matrix c which is returned by contour, contourc, contourf, and contour3. Contour labels are rotated to match the local line orientation and centered on the line. The position of labels along the contour line is chosen randomly.

If the argument h is a handle to a contour group object, then label this plot rather than the one in the current axes returned by gca.

By default, all contours are labeled. However, the contours to label can be specified by the vector v. If the "manual" argument is given then the contours to label can be selected with the mouse.

Additional property/value pairs that are valid properties of text objects can be given and are passed to the underlying text objects. Moreover, the contour group property "LabelSpacing" is available which determines the spacing between labels on a contour to be specified. The default is 144 points, or 2 inches.

The optional return value h is a vector of graphics handles to the text objects representing each label. The "userdata" property of the text objects contains the numerical value of the contour label.

An example of the use of clabel is

[c, h] = contour (peaks (), -4 : 6);
clabel (c, h, -4:2:6, "fontsize", 12);

See also: contour, contourf, contour3, meshc, surfc, text.

Demonstration 1

The following code

 clf;
 colormap ("default");
 [c, h] = contour (peaks (), -4:6);
 clabel (c, h, -4:2:6, "fontsize", 12);
 title ("clabel() labeling every other contour");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 colormap ("default");
 [c, h] = contourf (peaks (), -7:6);
 clabel (c, h, -6:2:6, "fontsize", 12);
 title ("clabel() labeling every other contour");

Produces the following figure

Figure 1

Package: octave