text(x,y,'text')
text(x,y,z,'text')
text('PropertyName','PropertyValue'....)
h = text(...)
text
is both a high-level graphics command for adding text to a plot, and a low-level graphics function for creating text objects.
Text objects are children of axes. text
is an object creation function that accepts property name/property value pairs as input arguments. These properties, which control various aspects of the text object, are described under "Object Properties." You can also set and query property values after creating the object using the set
and get
commands.
text(x,y,'text')
adds the string in the quotes to the location identified by the point (x,y)
to the current axes. Specify the point (x,y)
in units of the current plot's data. If x
and y
are vectors, text
writes the string at all locations defined by the list of points. h
is the handle of the created text object. The x
, y pair can be followed by property name/property value (
'PropertyName','PropertyValue'
) pairs to specify additional text properties.
If the text string is an array that is the same length as x
and y
, text
writes the corresponding row of the text array at each point specified by x
and y
.
text(x,y,z,'text')
adds text in three-dimensional coordinates. The x
, y
, z
triple for three-dimensional can be followed by property name/property value ('PropertyName','PropertyValue'
) pairs to specify additional text properties.
text('PropertyName','PropertyValue'....)
omits the x
, y
, pair (x
, y
, z
triple for three-dimensional) entirely and specifies all properties using property name/property value pairs.
h = text(..)
returns a handle to a text object.
ButtonDownFcn
eval
function to execute the specified function. Initially the empty matrix.Children
Clipping
on
(Default.) Any portion of the text outside the axes rectangle is not displayed.off
Text object is not clipped.Color
ColorSpec reference page for more information on specifying color.EraseMode
normal
(Default.) Redraws the affected region of the display, performing the three-dimensional analysis necessary to ensure that all objects are rendered correctly. This mode produces the most accurate picture, but is the slowest. The other modes are faster, but do not perform a complete redraw and are therefore less accurate.none
The text is not erased when it is moved or destroyed.xor
The text is drawn and erased by performing an exclusive OR (XOR) with the color of the screen beneath it. When the text is erased, it does not damage the objects beneath it. Text objects are dependent on the color of the screen beneath them, however, and are correctly colored only when over the figure background color.background
Text is erased by drawing it in the figure's background color. This damages objects that are behind the erased text, but text objects are always properly colored.Extent
[left,bottom,width,height]
, that defines the size and position of the text string. left
and bottom
are the distance from the lower-left corner of the figure window to the lower-left corner of the rectangle. width
and height
are the dimensions of the text rectangle. All measurements are in units specified by the Units
property.FontAngle
normal
(Default.) Regular font angle.italic
Italics.oblique
Italics on some systems.FontAngle
property.FontName
FontSize
FontWeight
normal
(Default.) Regular font weight.bold
Bold weight.HorizontalAlignment
left
(Default.) Text is left-justified with respect to its Position
.center
Text is centered with respect to its Position
.right
Text is right-justified with respect to its Position
.Interruptible
yes
The callback specified by ButtonDownFcn
is interruptible by other callbacks.no
(Default.) The ButtonDownFcn
callback is not interruptible.Parent
Position
[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
String
Type
'text'
for a text object.Units
data
(Default.) Data units of the parent axes.pixels
Screen pixels.normalized
Normalized coordinates, where the lower-left corner of the axes maps to (0,0) and the upper-right corner to (1.0,1.0).inches
Inches.cent
Centimeters.points
Points. Each point is equivalent to 1/72 of an inch.Extent
and Position
properties. All units are measured from the lower-left corner of the window. 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
get
command.
VerticalAlignment
top
String is placed at the top of the specified y-position.cap
Font's capital letter height is placed at the specified y-position.middle
(Default.) String is placed at the middle of the specified y-position.baseline
Font's baseline is placed at the specified y-position.bottom
String is placed at the bottom of the specified y-position.Visible
on
(Default.) Text is visible on the screen.off
Text is not visible on the screen.
annotate the point atplot([1 5 10],[1 10 20],'x')
text(5,10,' Action point')
(5,10)
with the string Action point
, while
marks two curves so you can easily distinguish them.plot(x1,y1,x2,y2)
text(x1,y1,'1'), text(x2,y2,'2')
gtext
,int2str
,num2str
,plot
,title
,xlabel
(c) Copyright 1994 by The MathWorks, Inc.