Label contour plot elevation - MATLAB clabel - MathWorks Deutschland (2024)

Table of Contents
Syntax Description Examples Label Contour Plot Levels Label Specific Contour Levels Set Contour Label Properties Label Contour Plot with Vertical Text Input Arguments C — Contour matrix two-row matrix h — Contour object contour object v — Contour level values vector Name-Value Arguments LabelSpacing — Space between labels scalar EdgeColor — Color of text box outline 'none' (default) | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' | ... BackgroundColor — Background color 'none' (default) | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' | ... FontSize — Font size 10 (default) | scalar value greater than 0 FontSmoothing — Font smoothing 'on' (default) | on/off logical value FontUnits — Font size units 'points' (default) | 'inches' | 'centimeters' | 'characters' | 'normalized' | 'pixels' Rotation — Text orientation 0 (default) | scalar Interpreter — Interpretation of text characters 'tex' (default) | 'latex' | 'none' LineStyle — Line style of text box outline '-' (default) | '--' | ':' | '-.' | 'none' LineWidth — Width of text box outline 0.5 (default) | scalar Margin — Space around text within the text box 3 (default) | scalar Output Arguments t — Text objects vector tl — Text and line objects vector Extended Capabilities GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™. Distributed ArraysPartition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™. Version History R2023b: Setting Color name-value argument also sets LabelColor of Contour object R2022a: FontSmoothing will have no effect in a future release See Also Functions Properties MATLAB-Befehl Americas Europe Asia Pacific References

Label contour plot elevation

collapse all in page

Syntax

clabel(C,h)

clabel(C,h,v)

clabel(C,h,'manual')

t = clabel(C,h,'manual')

clabel(C)

clabel(C,v)

clabel(C,'manual')

tl = clabel(___)

clabel(___,Name,Value)

Description

example

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

example

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

clabel(C,h,'manual') labelsthe locations you select with the mouse. Click the mouse or pressthe space bar to label the contour closest to the center of the crosshair.Press the Return key while the cursor is within thefigure window to terminate labeling.

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

example

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

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

clabel(C,'manual') addsupright labels at the locations you select with the mouse. Click themouse or press the space bar to label the contour closest to the centerof the crosshair. Press the Return key while thecursor is within the figure window to terminate labeling.

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

example

clabel(___,Name,Value) modifiesthe label appearance using one or more Name,Value pairarguments. Use any of the input argument combinations in the previoussyntaxes. For example, 'FontSize',14 sets the fontsize to 14 points.

Examples

collapse all

Label Contour Plot Levels

Open Live Script

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 contour plot elevation - MATLAB clabel- MathWorks Deutschland (1)

Label Specific Contour Levels

Open Live Script

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)

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (2)

Open Live Script

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')

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (3)

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')

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (4)

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

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

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (5)

Label Contour Plot with Vertical Text

Open Live Script

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)

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (6)

Input Arguments

collapse all

CContour matrix
two-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).

hContour object
contour object

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

vContour level values
vector

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

Example: [0 10 20]

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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

clabel supports the LabelSpacing propertyplus a subset of text properties.

LabelSpacingSpace between labels
scalar

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)

EdgeColorColor of text box outline
'none' (default) | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' | ...

Color of text box outline, specified as 'none', an RGB triplet, a hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • 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].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (7)

"green""g"[0 1 0]"#00FF00"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (8)

"blue""b"[0 0 1]"#0000FF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (9)

"cyan" "c"[0 1 1]"#00FFFF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (10)

"magenta""m"[1 0 1]"#FF00FF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (11)

"yellow""y"[1 1 0]"#FFFF00"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (12)

"black""k"[0 0 0]"#000000"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (13)

"white""w"[1 1 1]"#FFFFFF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (14)

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (15)

[0.8500 0.3250 0.0980]"#D95319"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (16)

[0.9290 0.6940 0.1250]"#EDB120"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (17)

[0.4940 0.1840 0.5560]"#7E2F8E"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (18)

[0.4660 0.6740 0.1880]"#77AC30"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (19)

[0.3010 0.7450 0.9330]"#4DBEEE"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (20)

[0.6350 0.0780 0.1840]"#A2142F"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (21)

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

BackgroundColorBackground color
'none' (default) | RGB triplet | hexadecimal color code | 'r' | 'g' | 'b' | ...

Color of text box background, specified as 'none', an RGB triplet, hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • 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].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (22)

"green""g"[0 1 0]"#00FF00"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (23)

"blue""b"[0 0 1]"#0000FF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (24)

"cyan" "c"[0 1 1]"#00FFFF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (25)

"magenta""m"[1 0 1]"#FF00FF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (26)

"yellow""y"[1 1 0]"#FFFF00"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (27)

"black""k"[0 0 0]"#000000"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (28)

"white""w"[1 1 1]"#FFFFFF"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (29)

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (30)

[0.8500 0.3250 0.0980]"#D95319"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (31)

[0.9290 0.6940 0.1250]"#EDB120"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (32)

[0.4940 0.1840 0.5560]"#7E2F8E"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (33)

[0.4660 0.6740 0.1880]"#77AC30"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (34)

[0.3010 0.7450 0.9330]"#4DBEEE"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (35)

[0.6350 0.0780 0.1840]"#A2142F"

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (36)

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

FontSizeFont size
10 (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)

FontSmoothingFont smoothing
'on' (default) | on/off logical value

Font smoothing, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • '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')

Note

The FontSmoothing name-value argument will have no effect in a future release. Font smoothing will be enabled regardless of the value.

FontUnitsFont 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 youresize the axes, the font size modifies accordingly. For example,if the FontSize is 0.1 in normalizedunits, then the text is 1/10 of the axes height.
'pixels'

Pixels.

Starting in R2015b, distances inpixels 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 aninch.

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

If you set both the font size and the font units in one functioncall, you must set the FontUnits property firstso that the axes correctly interprets the specified font size.

Note

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

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

RotationText orientation
0 (default) | scalar

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

Note

The clabel(C,h) and clabel(C,h,v) syntaxesdo not support this option. Instead, they insert rotated text intothe contour lines, with each label rotated to match the local orientationof the corresponding line.

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

InterpreterInterpretation of text characters
'tex' (default) | 'latex' | 'none'

Interpretation of text characters, specified as one of thesevalues:

  • 'tex' — Display text usingTeX markup.

  • 'latex' — Display text usingLaTeX markup.

  • 'none' — Display literalcharacters.

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

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

LineStyleLine style of text box outline
'-' (default) | '--' | ':' | '-.' | 'none'

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

Line StyleDescriptionResulting Line
"-"Solid line

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (37)

"--"Dashed line

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (38)

":"Dotted line

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (39)

"-."Dash-dotted line

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (40)

"none"No lineNo line

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

LineWidthWidth of text box outline
0.5 (default) | scalar

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

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

MarginSpace around text within the text box
3 (default) | scalar

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

MATLAB uses the Extent property valueplus the Margin property value to determine thesize of the text box.

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

Output Arguments

collapse all

t — Text objects
vector

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

tl — Text and line objects
vector

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

Extended Capabilities

Version History

Introduced before R2006a

expand all

If you set the Color name-value argument when you call the clabel function, the LabelColor property of the Contour object updates to the specified color value.

The FontSmoothing name-value argument will have no effect in a future release. Font smoothing will be enabled for all contour labels regardless of the value of the argument.

See Also

Functions

  • contour | contourc | contourf | contour3

Properties

  • Text Properties

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Label contour plot elevation - MATLAB clabel- MathWorks Deutschland (41)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Label contour plot elevation - MATLAB clabel
- MathWorks Deutschland (2024)

References

Top Articles
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 5823

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.