clabel

Contour labeling

📝 Syntax

  • clabel(C,h)

  • clabel(C,h,v)

  • clabel(C)

  • clabel(C,v)

  • tl = clabel(...)

  • clabel(...,Name,Value)

📥 Input argument

  • C -

Contour matrix returned by contour, contourf, or contour3. If you pass a contour object h, you may pass [] for C.

  • h -

Contour object handle returned by contour / contourf / contour3. When provided, labeling uses information attached to the contour object (levels and contour matrix).

  • v -

Vector of contour levels to label. When provided, only these levels receive labels.

📤 Output argument

  • t -

Text objects created by clabel. The String properties contain the contour values displayed.

  • tl -

Text and line objects created when upright markers are used (for clabel(C)-style usage).

📄 Description

The clabel function inserts labels into contour plots:

  • Provide a contour matrix C and contour object h to label rotated text along contour lines.

  • Provide only C to add upright labels and '+' markers at contour locations.

  • Pass a vector of levels v to label only specific contour values.

  • Use Name,Value pairs to control text appearance (a subset of Text properties, plus LabelSpacing).

💡 Examples

Label contour plot levels (basic).


figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
clabel(C,h)

Label specific contour levels.


figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
v = [2,6];
clabel(C,h,v)

Set contour label properties with Name,Value pairs.


figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
clabel(C,h,'FontSize',15,'Color','red')

Label using only the contour matrix (upright labels).


figure();
[x,y,z] = peaks;
C = contour(x,y,z);
clabel(C)

🔗 See also

contour, contourf, contourc.

🕔 History

Version
📄 Description

1.15.0

initial version

Last updated

Was this helpful?