Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

annotation - Create annotation objects

Syntax

annotation(annotation_type)
annotation('line',x,y)
annotation('arrow',x,y)
annotation('doublearrow',x,y)
annotation('textarrow',x,y)
annotation('textbox',[x y w h])
annotation('ellipse',[x y w h])
annotation('rectangle',[x y w h])
annotation(figure_handle,...)
annotation(...,'PropertyName',PropertyValue,...)
anno_obj_handle = annotation(...)

Description

annotation(annotation_type) creates the specified annotation type using default values for all properties. annotation_type can be one of the following strings:

annotation('line',x,y) creates a line annotation object that extends from the point defined by x(1),y(1) to the point defined by x(2),y(2), specified in normalized figure units.

annotation('arrow',x,y) creates an arrow annotation object that extends from the point defined by x(1),y(1) to the point defined by x(2),y(2), specified in normalized figure units.

annotation('doublearrow',x,y) creates a two-headed annotation object that extends from the point defined by x(1),y(1) to the point defined by x(2),y(2), specified in normalized figure units.

annotation('textarrow',x,y) creates a textarrow annotation object that extends from the point defined by x(1),y(1) to the point defined by x(2),y(2), specified in normalized figure units. The tail end of the arrow is attached to an editable text box.

annotation('textbox',[x y w h]) creates an editable text box annotation with its lower left corner at the point x,y, a width w, and a height h, specified in normalized figure units. Specify x, y, w, and h in a single vector.

To type in the text box, enable plot edit mode (plotedit) and double-click within the box.

annotation('ellipse',[x y w h]) creates an ellipse annotation with the lower left corner of the bounding rectangle at the point x,y, a width w, and a height h, specified in normalized figure units. Specify x, y, w, and h in a single vector.

annotation('rectangle',[x y w h]) creates a rectangle annotation with the lower left corner of the rectangle at the point x,y, a width w, and a height h, specified in normalized figure units. Specify x, y, w, and h in a single vector.

annotation(figure_handle,...) creates the annotation in the specified figure.

annotation(...,'PropertyName',PropertyValue,...) creates the annotation and sets the specified properties to the specified values.

anno_obj_handle = annotation(...) returns the handle to the annotation object.

Examples

Create a globe with a textarrow annotation object showing where MathWorks™ headquarters is:

% Create a sphere and color it using a topographic colormap:
cla reset;
load topo;
[x y z] = sphere(45);
s = surface(x,y,z,'facecolor','texturemap','cdata',topo);
colormap(topomap1);
% Brighten the colormap for better annotation visibility:
brighten(.6)
% Create and arrange the camera and lighting for better visibility:
campos([2 13 10]);
camlight;
lighting gouraud;
axis off vis3d;
% Set the x- and y-coordinates of the textarrow object:
x = [0.7698 0.5851];
y = [0.3593 0.5492];
% Create the textarrow object: 
txtar =  annotation('textarrow',x,y,'string','We are here.','FontSize',14);

Alternatives

Create several types of annotations with the Figure Palette and modify annotations with the Property Editor, components of the plotting tools. Directly manipulate annotations in plot edit mode. For details, see How to Annotate Graphs and Working in Plot Edit Mode in the MATLAB Graphics documentation.

See Also

Annotation Arrow Properties | Annotation Doublearrow Properties | Annotation Ellipse Properties | Annotation Line Properties | Annotation Rectangle Properties | Annotation Textarrow Properties | Annotation Textbox Properties

How To

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS