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.

Annotation Text Arrow Properties

Control annotation text arrow appearance and behavior

Annotation text arrow properties control the appearance and behavior of an annotation text arrow object. By changing property values, you can modify certain aspects of the text arrow.

Starting in R2014b, you can use dot notation to query and set properties.

h = annotation('textarrow');
s = h.FontSize;
h.FontSize = 12;

If you are using an earlier release, use the get and set functions instead.

Text

expand all

StringText to display'' (default) | character array | cell array | numeric value

Text to display, specified as a character array, cell array, or numeric value.

Example: 'my label'

Example: {'first line','second line'}

Example: 123

To include numeric variables with text, use the num2str function. For example:

x = 42;
str = ['The value is ',num2str(x)];

To include special characters, such as superscripts, subscripts, Greek letters, or mathematical symbols use TeX markup. For a list of supported markup, see the Interpreter property.

To create multiline text:

  • Use a cell array, where each cell contains a line of text, such as {'first line','second line'}.

  • Use a character array, where each row contains the same number of characters, such as ['abc'; 'ab '].

  • Use sprintf to create text with a new line character, such as sprintf('first line \n second line'). This property converts text with new line characters to cell arrays.

Text that contains only a numeric value is converted using sprintf('%g',value). For example, 12345678 displays as 1.23457e+07.

    Note:   The words default, factory, and remove are reserved words that will not appear in text when quoted as a normal characters. To display any of these words individually, precede them with a backslash, such as '\default' or '\remove'.

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

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

  • 'tex' — Interpret characters using a subset of TeX markup.

  • 'latex' — Interpret characters using LaTeX markup.

  • 'none' — Display literal characters.

TeX Markup

By default, MATLAB® supports a subset of TeX markup. Use TeX markup to add superscripts and subscripts, modify the font type and color, and include special characters in the text.

This table lists the supported modifiers with the Interpreter property set to 'tex'. Modifiers remain in effect until the end of the text. Superscripts and subscripts are an exception because they only modify the next character or the characters within the curly braces.

ModifierDescriptionExample
^{ }Superscript'text^{superscript}'
_{ }Subscript'text_{subscript}'
\bfBold font'\bf text'
\itItalic font'\it text'
\slOblique font (usually the same as italic font)'\sl text'
\rmNormal font'\rm text'
\fontname{specifier}Font name — Set specifier as the name of a font family. You can use this in combination with other modifiers.'\fontname{Courier} text'
\fontsize{specifier}Font size — Set specifier as a numeric scalar value in point units to change the font size.'\fontsize{15} text'
\color{specifier}Font color — Set specifer as one of these colors: red, green, yellow, magenta, blue, black, white, gray, darkGreen, orange, or lightBlue.'\color{magenta} text'
\color[rgb]{specifier}Custom font color — Set specifier as a three-element RGB triplet.'\color[rgb]{0,0.5,0.5} text'

This table lists the supported special characters with the Interpreter property set to 'tex'.

Character SequenceSymbolCharacter SequenceSymbolCharacter SequenceSymbol

\alpha

α

\upsilon

υ

\sim

~

\angle

\phi

Φ

\leq

\ast

*

\chi

χ

\infty

\beta

β

\psi

ψ

\clubsuit

\gamma

γ

\omega

ω

\diamondsuit

\delta

δ

\Gamma

Γ

\heartsuit

\epsilon

ɛ

\Delta

Δ

\spadesuit

\zeta

ζ

\Theta

Θ

\leftrightarrow

\eta

η

\Lambda

Λ

\leftarrow

\theta

Θ

\Xi

Ξ

\Leftarrow

\vartheta

ϑ

\Pi

Π

\uparrow

\iota

ι

\Sigma

Σ

\rightarrow

\kappa

κ

\Upsilon

ϒ

\Rightarrow

\lambda

λ

\Phi

Φ

\downarrow

\mu

µ

\Psi

Ψ

\circ

º

\nu

ν

\Omega

Ω

\pm

±

\xi

ξ

\forall

\geq

\pi

π

\exists

\propto

\rho

ρ

\ni

\partial

\sigma

σ

\cong

\bullet

\varsigma

ς

\approx

\div

÷

\tau

τ

\Re

\neq

\equiv

\oplus

\aleph

\Im

\cup

\wp

\otimes

\subseteq

\oslash

\cap

\in

\supseteq

\supset

\lceil

\subset

\int

\cdot

·

\o

ο

\rfloor

\neg

¬

\nabla

\lfloor

\times

x

\ldots

...

\perp

\surd

\prime

´

\wedge

\varpi

ϖ

\0

\rceil

\rangle

\mid

|

\vee

\langle

\copyright

©

LaTeX Markup

To use LaTeX markup, set the Interpreter property to 'latex'. Use dollar symbols around the text, for example, use '$\int_1^{20} x^2 dx$' for inline mode or '$$\int_1^{20} x^2 dx$$' for display mode.

The displayed text uses the default LaTeX font style. The FontName, FontWeight, and FontAngle properties do not have an effect. To change the font style, use LaTeX markup.

The maximum size of the text that you can use with the LaTeX interpreter is 1200 characters. For multiline text, this reduces by about 10 characters per line.

For more information about the LaTeX system, see The LaTeX Project website at http://www.latex-project.org/.

TextColorText color[0 0 0] (default) | RGB triplet | color string | 'none'

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

    Note:   Setting the Color property changes the TextColor property to the same value, unless you explicitly set the TextColor property.

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]

TextRotationText rotation angle in degrees0 (default) | scalar numeric value

Text rotation angle in degrees, specified as a scalar numeric value. Set this property to a positive value to rotate the text counterclockwise. Angles are absolute and not relative to previous rotations. A rotation of 0 degrees is always horizontal.

Example: 90

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Font Style

expand all

FontAngleCharacter 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.

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

FontSizeFont size10 (default) | scalar value greater than 0

Font size, specified as a scalar value greater than 0 in point units. One point equals 1/72 inch. To change the font units, use the FontUnits property.

Example: 12

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

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 uicontrol font of the graphics root object:
  • 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.

FontWeightThickness 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.

Text Box

expand all

TextLineWidthWidth of text box outline0.5 (default) | scalar numeric value

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

Example: 1.5

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

TextEdgeColorColor 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. If the color is 'none', the box outline 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]

TextBackgroundColorColor 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. If the color is 'none', the background color 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]

TextMarginSpace around text within text box2 (default) | scalar numeric value

Space around the text within the text box, specified as a scalar numeric value in pixel units.

Example: 10

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Arrow

expand all

ColorArrow color[0 0 0] (default) | RGB triplet | color string | 'none'

Arrow color, specified as a three-element RGB triplet, a color string, or 'none'. The default RGB triplet value of [0 0 0] corresponds to black. If you set the color to 'none', then the arrow is invisible.

    Note:   Setting this property also changes the text color if you have not explicitly set the text color using the TextColor property.

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]

LineStyleLine style'-' (default) | '--' | ':' | '-.' | 'none'

Line style, specified as one of the line style values listed in this table.

ValueDescriptionResult
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

LineWidthWidth of arrow stem0.5 (default) | scalar numeric value

Width of arrow stem, specified as a scalar numeric value greater than zero in point units. One point equals 1/72 inch. The default value is 0.5 points.

Example: 0.75

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

HeadStyleStyle of arrowhead'vback2' (default) | head style string

Style of the arrowhead, specified as one of the head style strings in this table.

StringResultStringResult
'plain'

'fourstar'

'ellipse'

'rectangle'

'vback1'

'diamond'

'vback2' (default)

'rose'

'vback3'

'hypocycloid'

'cback1'

'astroid'

'cback2'

'deltoid'

'cback3'

'none'No arrowhead

HeadLengthLength of arrowhead10 (default) | scalar numeric value

Length of the arrowhead, specified as a scalar numeric value in point units. One point equals 1/72 inch.

Example: 15

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

HeadWidthWidth of arrowhead10 (default) | scalar numeric value

Width of the arrowhead, specified as a scalar numeric value in point units. One point equals 1/72 inch.

Example: 15

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Location and Size

expand all

XBeginning and ending x-coordinates[0.3 0.4] (default) | two-element vector

Beginning and ending x-coordinates for the arrow, specified as a two-element vector of the form [x_begin x_end].

By default, the units are normalized to the figure. The lower-left corner of the figure maps to (0,0), and the upper-right corner maps to (1,1). To change the units, use the Units property.

Example: [0.2 0.3]

YBeginning and ending y-coordinates[0.3 0.4] (default) | two-element vector

Beginning and ending y-coordinates for the arrow, specified as a two-element vector of the form [y_begin y_end].

By default, the units are normalized to the figure. The lower-left corner of the figure maps to (0,0), and the upper-right corner maps to (1,1). To change the units, use the Units property.

Example: [0.2 0.3]

PositionSize and location[0.3 0.3 0.1 0.1] (default) | four-element vector

Size and location, specified as a four-element vector of the form [x_begin y_begin length height]. The first two elements specify the coordinates of the beginning of the arrow. The second two elements specify the length and height of the arrow. The text box extends from the beginning of the arrow.

By default, the units are normalized to the figure. The lower-left corner of the figure maps to (0,0), and the upper-right corner maps to (1,1). To change the units, use the Units property.

Example: [0.2 0.2 0.3 0.1]

UnitsPosition units'normalized' (default) | 'inches' | 'centimeters' | 'characters' | 'points' | 'pixels'

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

UnitsDescription
'normalized' (default)Normalized with respect to the figure, uipanel, or uitab that contains the annotation. The lower-left corner of the container maps to (0,0) and the upper-right corner maps to (1,1).
'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.

'points'Points. One point equals 1/72 inch.
'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.

All units are measured from the lower-left corner of the figure window.

This property affects the Position property. If you change the units, then it is good practice to return it to the default value after completing your computation to prevent affecting other functions that assume Units is set to the default value.

If you specify the Position and Units properties as Name,Value pairs when creating the annotation text arrow, then the order of specification matters. If you want to define the position with particular units, then you must set the Units property before the Position property.

HorizontalAlignmentHorizontal alignment of text'left' (default) | 'center' | 'right'

Horizontal alignment of the text, specified as one of the values in this table. This property is useful when aligning multiple lines of text.

ValueResult
'left'

'center'

'right'

VerticalAlignmentVertical alignment of text with respect to arrow'top' (default) | 'cap' | 'middle' | 'baseline' | 'bottom'

Vertical alignment of the text with respect to the end of the arrow, specified as 'top', 'cap', 'middle', 'baseline', or 'bottom'.

Was this topic helpful?