Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

clabel

Label contour plot elevation

Syntax

  • clabel(C,h)
    example
  • clabel(C,h,v)
    example
  • clabel(C,h,'manual')
  • t = clabel(C,h,'manual')
  • clabel(C)
    example
  • clabel(C,v)
  • clabel(C,'manual')
  • tl = clabel(___)

Description

example

clabel(C,h) labels the current contour plot with rotated text inserted into each contour line. The contour lines must be long enough to fit the label, otherwise clabel does not insert a label. If you do not have the contour matrix C, then replace C with [].

example

clabel(C,h,v) labels the contour levels specified by vector v.

clabel(C,h,'manual') 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 crosshair. Press the Return key while the cursor is within the figure window to terminate labeling.

t = clabel(C,h,'manual') returns the text objects created.

example

clabel(C) labels contours with '+' symbols and upright text.

clabel(C,v) adds upright labels to the contour levels specified by the vector, v.

clabel(C,'manual') adds upright labels at 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 crosshair. Press the Return key while the cursor is within the figure window to terminate labeling.

tl = clabel(___) returns the text and line objects created. Use any of the input argument combinations in the previous syntaxes that do not include the contour object h.

example

clabel(___,Name,Value) modifies the label appearance using one or more Name,Value pair arguments. Use any of the input argument combinations in the previous syntaxes. For example, 'FontSize',14 sets the font size to 14 points.

Examples

collapse all

Label Contour Plot Levels

Create a contour plot and obtain the contour matrix, C, and the contour object, h. Then, label the contour plot.

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

Label Specific Contour Levels

Label only the contours with contour levels 2 or 6.

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

Set Contour Label Properties

Set the font size of the labels to 15 points and set the color to red using Name,Value pair arguments.

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

Set additional properties by reissuing the clabel command. For example, set the font weight to bold and change the color to blue.

clabel(C,h,'FontWeight','bold','Color','blue')

Set the font size back to the default size using the 'default' keyword.

clabel(C,h,'FontSize','default')

Label Contour Plot with Vertical Text

Create a contour plot and return the contour matrix, C. Then, label the contours.

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

Input Arguments

collapse all

C — Contour matrixtwo-row matrix

Contour matrix returned by the contour, contour3, or contourf function. C contains the data that defines the contour lines. For more information on the contour matrix, see ContourMatrix.

    Note:   If you pass the contour object h to the clabel function, then you can replace C with []. For example, use clabel([],h).

h — Contour objectcontour object

Contour object returned by the contour, contour3, or contourf function.

v — Contour level valuesvector

Contour level values, specified as a row or column vector of individual values.

Example: [0 10 20]

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: clabel(C,h,'Color','red','FontSize',12) specifies red, 12-point labels.

clabel supports the LabelSpacing property plus a subset of text properties.

'LabelSpacing' — Space between labelsscalar

Space between labels, specified as a scalar value in point units.

    Note:   Use this option with either the clabel(C,h) or clabel(C,h,v) syntax. Other syntaxes do not support this option.

Example: clabel(C,h,'LabelSpacing',100)

'Color' — Text color[0 0 0] (default) | RGB triplet | character vector | 'none'

Text color, specified as a three-element RGB triplet, a character vector of a color name, or 'none'. The default color is black with an RGB triplet value of [0 0 0]. If you set the color to 'none', then the text is invisible.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: 'blue'

Example: [0 0 1]

'EdgeColor' — Color of text box outline'none' (default) | RGB triplet | color string

Color of text box outline, specified as 'none', a three-element RGB triplet, or a color string. The default edge color of 'none' makes the box outline invisible.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: clabel(C,h,'EdgeColor','k')

'BackgroundColor' — Color of text box background'none' (default) | RGB triplet | color string

Color of text box background, specified as 'none', a three-element RGB triplet, or a color string. The default background color of 'none' makes the text box background transparent.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: clabel(C,h,'BackgroundColor','g')

'FontSize' — Font size10 (default) | scalar value greater than 0

Font size, specified as a scalar value greater than 0. By default, the font size uses point units. One point equals 1/72 inch. However, some syntaxes allow you to change the font units using the FontUnits property.

Example: clabel(C,h,'FontSize',15)

'FontName' — Font name'Helvetica' (default) | 'FixedWidth' | system supported font name

Font name, specified as the name of the font to use or 'FixedWidth'. To display and print properly, the font name must be a font that your system supports.

To use a fixed-width font that looks good in any locale, use 'FixedWidth'. The 'FixedWidth' value relies on the root FixedWidthFontName property. Setting the root FixedWidthFontName property causes an immediate update of the display to use the new font.

Example: 'Cambria'

'FontAngle' — Character slant'normal' (default) | 'italic'

Character slant, specified as 'normal' or 'italic'. Not all fonts have both font styles. Therefore, the italic font might look the same as the normal font.

    Note:   The 'oblique' value has been removed. Use 'italic' instead.

'FontWeight' — Thickness of text characters'normal' (default) | 'bold'

Thickness of the text characters, specified as one of these values:

  • 'normal' — Default weight as defined by the particular font

  • 'bold' — Thicker character outlines than normal

MATLAB® uses the FontWeight property to select a font from those available on your system. Not all fonts have a bold font weight. Therefore, specifying a bold font weight still can result in the normal font weight.

    Note:   The 'light' and 'demi' font weight values have been removed. Use 'normal' instead.

'FontSmoothing' — Smooth font character appearance'on' (default) | 'off'

Smooth font character appearance, specified as one of these values:

  • 'on' — Apply font smoothing. Reduce the appearance of jaggedness in the text characters to make the text easier to read.

  • 'off' — Do not apply font smoothing.

Example: clabel(C,h,'FontSmoothing','on')

'FontUnits' — Font size units'points' (default) | 'inches' | 'centimeters' | 'characters' | 'normalized' | 'pixels'

Font size units, specified as one of the values in this table.

UnitsDescription
'points'Points. One point equals 1/72 inch.
'inches'Inches.
'centimeters'Centimeters.
'characters'Based on the default system font character size.
  • Character width = width of letter x.

  • Character height = distance between the baselines of two lines of text.

'normalized'Interpret font size as a fraction of the axes height. If you resize the axes, the font size modifies accordingly. For example, if the FontSize is 0.1 in normalized units, then the text is 1/10 of the axes height.
'pixels'

Pixels.

Starting in R2015b, distances in pixels are independent of your system resolution on Windows® and Macintosh systems:

  • On Windows systems, a pixel is 1/96th of an inch.

  • On Macintosh systems, a pixel is 1/72nd of an inch.

On Linux® systems, the size of a pixel is determined by your system resolution.

If you set both the font size and the font units in one function call, you must set the FontUnits property first so that the axes correctly interprets the specified font size.

    Note:   The clabel(C,h) and clabel(C,h,v) syntaxes do not support this option. They always use the default value of points.

Example: clabel(C,'FontUnits','normalized')

'Rotation' — Text orientation0 (default) | scalar

Text orientation, specified as a scalar value in degrees. The default rotation of 0 degrees makes the text horizontal. For vertical text, set this property to 90 or -90. Positive values rotate the text counterclockwise. Negative values rotate the text clockwise.

    Note:   The clabel(C,h) and clabel(C,h,v) syntaxes do not support this option. Instead, they insert rotated text into the contour lines, with each label rotated to match the local orientation of the corresponding line.

Example: clabel(C,'Rotation',90)

'Interpreter' — Interpretation of text characters'tex' (default) | 'latex' | 'none'

Interpretation of text characters, specified as one of these values:

  • 'tex' — Display text using TeX markup.

  • 'latex' — Display text using LaTeX markup.

  • 'none' — Display literal characters.

Since the labels are numeric text strings, the effect of this property is limited to subtle changes in the font style and weight.

Example: clabel(C,h,'Interpreter','latex')

'LineStyle' — Line style of text box outline'-' (default) | '--' | ':' | '-.' | 'none'

Line style of text box outline, specified as one of the strings in this table.

StringLine StyleResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'Line is invisible 

Example: clabel(C,h,'LineStyle','--')

'LineWidth' — Width of text box outline0.5 (default) | scalar

Width of text box outline, specified as a scalar value in point units. One point equals 1/72 inch.

Example: clabel(C,h,'LineWidth',1)

'Margin' — Space around text within the text box3 (default) | scalar

The space around the text within the text box, specified as scalar value in point units.

MATLAB uses the Extent property value plus the Margin property value to determine the size of the text box.

Example: clabel(C,h,'Margin',4)

Output Arguments

collapse all

t — Text objectsvector

Text objects, returned as a vector. The String properties of the text objects contain the contour values displayed.

tl — Text and line objectsvector

Text and line objects, returned as a vector. The String properties of the text objects contain the contour values displayed. The line objects correspond to the '+' symbols.

See Also

Functions

Properties

Introduced before R2006a

Was this topic helpful?