How do I position annotations in a figure with respect to the axes in MATLAB 7.2 (R2006a)?

11 views (last 30 days)
When I place certain types of annotations using the ANNOTATION function, they are positioned relative to the figure rather than the axes. This is unexpected since I plotted the data relative to axis x and y rather than to the normalized position within a figure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Some annotations created with the ANNOTATION function are positioned relative to the figure coordinate space rather that the axes coordinate space. These include arrow, doublearrow, textarrow, and ellipse.
You can use the attached function named "axxy2figxy.m" to transform coordinates from data (axes) space to figure space. After downloading the attached function, use the following code to illustrate its use:
figure,line
[axx axy] = ginput(2); % click 2 separate places within the axes.
[figx figy] = axxy2figxy(gca, axx, axy);
har = annotation('textarrow',figx,figy);
  2 Comments
Adam Danz
Adam Danz on 30 Apr 2020
The annotation function needs to have a data-units option. The need to plot in figure units is relatively infrequent and it greatly limits the utility of the otherwise useful annotation() function.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!