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

arrowMATLABplace

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.

Best Answer

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);
Related Question