MATLAB Function Reference
  Go to function:
    Search    Help Desk 
Text Properties

Text Properties

This section lists property names along with the types of values each accepts. Curly braces { } enclose default values.

BusyAction                   cancel | {queue}

Callback routine interruption. The BusyAction property enables you to control how MATLAB handles events that potentially interrupt executing callback routines. If there is a callback routine executing, subsequently invoked callback routines always attempt to interrupt it. If the Interruptible property of the object whose callback is executing is set to on (the default), then interruption occurs at the next point where the event queue is processed. If the Interruptible property is off, the BusyAction property (of the object owning the executing callback) determines how MATLAB handles the event. The choices are:

ButtonDownFcn                string

Button press callback routine. A callback routine that executes whenever you press a mouse button while the pointer is over the Text object. Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.

Children                     matrix (read only)

The empty matrix; Text objects have no children.

Clipping                     on | {off}

Clipping mode. When Clipping is on, MATLAB does not display any portion of the Text that is outside the Axes.

Color                        ColorSpec

Text color. A three-element RGB vector or one of MATLAB 's predefined names, specifying the Text color. The default value for Color is white. See ColorSpec for more information on specifying color.

CreateFcn                    string

Callback routine executed during object creation. This property defines a callback routine that executes when MATLAB creates a Text object. You must define this property as a default value for Text. For example, the statement,

defines a default value on the Root level that sets the Figure Pointer property to a crosshair whenever you create a Text object. MATLAB executes this routine after setting all Text properties. Setting this property on an existing Text object has no effect.

The handle of the object whose CreateFcn is being executed is accessible only through the Root CallbackObject property, which you can query using gcbo.

DeleteFcn                    string

Delete Text callback routine. A callback routine that executes when you delete the Text object (e.g., when you issue a delete command or clear the Axes or Figure). MATLAB executes the routine before destroying the object's properties so these values are available to the callback routine.

The handle of the object whose DeleteFcn is being executed is accessible only through the Root CallbackObject property, which you can query using gcbo.

Editing                      on | {off}

Enable or disable editing mode. When this property is set to the default of off, you cannot edit the text string interactively (i.e., you must change the String property to change the text). When this property is set to on, MATLAB places an insert cursor at the beginning of the text string and enables editing. To apply the new text string:

MATLAB then updates the String property to contain the new text and resets the Editing property to off. You must reset the Editing property to on to again resume editing.

EraseMode                    {normal} | none | xor | background

Erase mode. This property controls the technique MATLAB uses to draw and erase Text objects. Alternative erase modes are useful for creating animated sequences, where controlling the way individual object redraw is necessary to improve performance and obtain the desired effect.

MATLAB always prints Figures as if the EraseMode of all objects is normal. This means graphics objects created with EraseMode set to none, xor, or background can look different on screen than on paper. On screen, MATLAB may mathematically combine layers of colors (e.g., XORing a pixel color with that of the pixel behind it) and ignore three-dimensional sorting to obtain greater rendering speed. However, these techniques are not applied to the printed output.

You can use the MATLAB capture command or other screen capture application to create an image of a Figure containing non-normal mode objects.

Extent                       position rectangle (read only)

Position and size of Text. A four-element read-only vector that defines the size and position of the Text string:

If the Units property is set to data (the default), left and bottom are the x and y coordinates of the lower-left corner of the Text Extent rectangle.

For all other values of Units, left and bottom are the distance from the lower-left corner of the Axes position rectangle to the lower-left corner of the Text Extent rectangle. width and height are the dimensions of the Extent rectangle. All measurements are in units specified by the Units property.

FontAngle                    {normal} | italic | oblique

Character slant. MATLAB uses this property to select a font from those available on your particular system. Generally, setting this property to italic or oblique selects a slanted font.

FontName                     string

Font family. A string specifying the name of the font to use for the Text object. To display and print properly, this must be a font that your system supports. The default font is Helvetica.

FontSize                     size in FontUnits

Font size. An integer specifying the font size to use for Text, in units determined by the FontUnits property. The default point size is 10 (1 point = 1/72 inch).

FontWeight                   light | {normal} | demi | bold

Weight of Text characters. MATLAB uses this property to select a font from those available on your particular system. Generally, setting this property to bold or demi causes MATLAB to use a bold font.

FontUnits                    {points} | normalized | inches |
                              centimeters | pixels

Font size units. MATLAB uses this property to determine the units used by the FontSize property. Normalized units interpret FontSize as a fraction of the height of the parent Axes. When you resize the Axes, MATLAB modifies the screen FontSize accordingly. pixels, inches, centimeters, and points are absolute units (1 point = 1/72 inch).

HandleVisibility             {on} | callback | off

Control access to object's handle by command-line users and GUIs. This property determines when an object's handle is visible in its parent's list of children. HandleVisibility is useful for preventing command-line users from accidentally drawing into or deleting a Figure that contains only user interface devices (such as a dialog box).

Handles are always visible when HandleVisibility is on.

Setting HandleVisibility to callback causes handles to be visible from within callback routines or functions invoked by callback routines, but not from within functions invoked from the command line. This provide a means to protect GUIs from command-line users, while allowing callback routines to have complete access to object handles.

Setting HandleVisibility to off makes handles invisible at all times. This may be necessary when a callback routine invokes a function that might potentially damage the GUI (such as evaluating a user-typed string), and so temporarily hides its own handles during the execution of that function.

When a handle is not visible in its parent's list of children, it cannot be returned by functions that obtain handles by searching the object hierarchy or querying handle properties. This includes get, findobj, gca, gcf, gco, newplot, cla, clf, and close.

When a handle's visibility is restricted using callback or off, the object's handle does not appear in its parent's Children property, Figures do not appear in the Root's CurrentFigure property, objects do not appear in the Root's CallbackObject property or in the Figure's CurrentObject property, and Axes do not appear in their parent's CurrentAxes property.

You can set the Root ShowHiddenHandles property to on to make all handles visible, regardless of their HandleVisibility settings (this does not affect the values of the HandleVisibility properties).

Handles that are hidden are still valid. If you know an object's handle, you can set and get its properties, and pass it to any function that operates on handles.

HitTest                      {on} | off

Selectable by mouse click. HitTest determines if the Text can become the current object (as returned by the gco command and the Figure CurrentObject property) as a result of a mouse click on the Text. If HiTest is off, clicking on the Text selects the object below it (which is usually the Axes containing it).

For example, suppose you define the button down function of an Image (see the ButtonDownFcn property) to display text at the location you click on with the mouse,

First define the callback routine,

Now display an Image, setting its ButtonDownFcn property to the callback routine:

When you click on the Image, MATLAB displays the text string at that location. With HitTest set to off, existing text cannot intercept any subsequent button down events that occur over the text. This enables the Image's button down function to execute.

HorizontalAlignment          {left} | center | right

Horizontal alignment of Text. This property specifies the horizontal justification of the Text string. It determines where MATLAB places the string with regard to the point specified by the Position property. The following picture illustrates the alignment options:


See the Extent property for related information.

Interpreter                  {tex} | none

Interpret Tex instructions. This property controls whether MATLAB interprets certain characters in the String property as Tex instructions (default) or displays all characters literally. See the String property for a list of support Tex instructions.

Interruptible                {on} | off

Callback routine interruption mode. The Interruptible property controls whether a Text callback routine can be interrupted by subsequently invoked callback routines. Text objects have four properties that define callback routines: ButtonDownFcn, CreateFcn, and DeleteFcn. See the BusyAction property for information on how MATLAB executes callback routines.

Parent                       handle

Text object's parent. The handle of the Text object's parent object. The parent of a Text object is the Axes in which it is displayed. You can move a Text object to another Axes by setting this property to the handle of the new parent.

Position                     [x,y,[z]]

Location of Text. A two- or three-element vector, [x y [z]], that specifies the location of the text in three dimensions. If you omit the z value, it defaults to 0. All measurements are in units specified by the Units property. Initial value is [0 0 0].

Rotation                     scalar (default = 0)

Text orientation. This property determines the orientation of the Text string. Specify values of rotation in degrees (positive angles cause counterclockwise rotation).

Selected                     on | {off}

Is object selected. When this property is on, MATLAB displays selection handles if the SelectionHighlight property is also on. You can, for example, define the ButtonDownFcn to set this property, allowing users to select the object with the mouse.

SelectionHighlight           {on} | off

Objects highlight when selected. When the Selected property is on, MATLAB indicates the selected state by drawing four edge handles and four corner handles. When SelectionHighlight is off, MATLAB does not draw the handles.

String                       string

The Text string. Specify this property as a quoted string for single-line strings, or as a cell array of strings or a padded string matrix for multiline strings. MATLAB displays this string at the specified location. Vertical slash characters are not interpreted as linebreaks in Text strings, and are drawn as part of the Text string. See the "Remarks" section for more information.

When the Text Interpreter property is Tex (the default), you can use a subset of TeX commands embedded in the string to produce special characters such as Greek letters and mathematical symbols. The following table lists these characters and the character sequence used to define them.

Character Sequence
Symbol
Character Sequence
Symbol
Character Sequence
Symbol
\alpha

\upsilon

\sim
~
\beta

\phi

\leq

\gamma

\chi

\infty

\delta

\psi

\clubsuit

\epsilon

\omega

\diamondsuit

\zeta

\Gamma

\heartsuit

\eta

\Delta

\spadesuit

\theta

\Theta

\leftrightarrow

\vartheta

\Lambda

\leftarrow

\iota

\Xi

\uparrow

\kappa

\Pi

\rightarrow

\lambda

\Sigma

\downarrow

\mu
µ
\Upsilon

\circ
º
\nu

\Phi

\pm
±
\xi

\Psi

\geq

\pi

\Omega

\propto

\rho

\forall

\partial

\sigma

\exists

\bullet

\varsigma

\ni

\div
÷
\tau

\cong

\neq

\equiv

\approx

\aleph

\Im

\Re

\wp

\otimes

\oplus

\oslash

\cap

\cup

\supseteq

\supset

\subseteq

\subset

\int

\in

\o

\rfloor

\lceil

\nabla

\lfloor

\cdot
·
\ldots
...
\perp

\neg
¬
\prime
'
\wedge

\times
x
\0

\rceil

\surd

\mid
|
\vee

\varpi

\copyright
©
\langle

\rangle



You can also specify stream modifiers that control the font used. The first four modifiers are mutually exclusive. However, you can use \fontname in combination with one of the other modifiers:

Stream modifiers remain in effect until the end of the string or only within the context defined by braces { }.

The subscript character "_" and the superscript character "^" modify the character or substring defined in braces immediately following.

To print the special characters used to define the Tex strings when Interpreter is Tex, prefix them with the backslash "\" character: \\, \{, \} \_, \^.

See the "Example" section for more information.

When Interpreter is none, no characters in the String are interpreted, and all are displayed when the text is drawn.

Tag                          string

User-specified object label. The Tag property provides a means to identify graphics objects with a user-specified label. This is particularly useful when constructing interactive graphics programs that would otherwise need to define object handles as global variables or pass them as arguments between callback routines. You can define Tag as any string.

Type                         string (read only)

Class of graphics object. For Text objects, Type is always the string 'text'.

Units                        pixels | normalized | inches |
                             centimeters | points | {data}

Units of measurement. This property specifies the units MATLAB uses to interpret the Extent and Position properties. All units are measured from the lower-left corner of the Axes plotbox. Normalized units map the lower-left corner of the rectangle defined by the Axes to (0,0) and the upper-right corner to (1.0,1.0). pixels, inches, centimeters, and points are absolute units (1 point = 1/72 inch). data refers to the data units of the parent Axes.

If you change the value of Units, it is good practice to return it to its default value after completing your computation so as not to affect other functions that assume Units is set to the default value.

UserData                     matrix

User-specified data. Any data you want to associate with the Text object. MATLAB does not use this data, but you can access it using set and get.

UIContextMenu                handle of a uicontextmenu object

Associate a context menu with the Text. Assign this property the handle of a Uicontextmenu object created in the same Figure as the Text. Use the uicontextmenu function to create the context menu. MATLAB displays the context menu whenever you right-click over the Text (Control-click on Macintosh systems)

VerticalAlignment            top | cap | {middle} | baseline |
                             bottom

Vertical alignment of Text. This property specifies the vertical justification of the text string. It determines where MATLAB places the string with regard to the value of the Position property. The possible values mean:

The following picture illustrates the alignment options:


Visible                      {on} | off

Text visibility. By default, all Text is visible. When set to off, the Text is not visible, but still exists and you can query and set its properties.



[ Previous | Help Desk | Next ]