Is it possible to annotate arrows (or other annotation objects) in subplots?

10 views (last 30 days)
I want to draw an arrow in one of my subplots at a specific point to mark a zero-crossing. But after I have converted the x and y positions from data space coordiantes to normalized figure space coordinates the arrow is displayed in the figure itself and not inside the subplot were I want it. It seems like MATLAB will only accept a figure handle and not an axis handle for the annotation command. Can anyone tell me wether it is possible at all to draw arrows in a subplot??? Is there an alternative option (other than Paint)??
I've simplified my code to:
subplot(4,2,5);
hold on
plot([xlim(1) xlim(2)],[0 0],'Color',[0.9 0.9 0.9])
plot(xvalues,yvalues)
xlim([xlim(1) xlim(2)])
% Transforming x and y values from data space to figure space
axlim = axis(gca);
arrowx = ([zero-cross zero-cross]-axlim(1))./(axlim(2)-axlim(1));
arrowy = ([-0.1 0]-axlim(3))./(axlim(4)-axlim(3));
% Plotting the arrow
annotation('arrow',arrowx,arrowy);
Thanks, Sabrina

Accepted Answer

Sean de Wolski
Sean de Wolski on 27 Feb 2013
You could also use a quiver plot.
  1 Comment
Sabrina Wendt
Sabrina Wendt on 27 Feb 2013
Thanks for answering! I had a little trouble getting the pinned_annotation to work. It seems like in order for the arrows to be plotted, that pinned_annotation has to be the first command you state after the subplot command before plotting normally, even when creating a handle to the axes. I have given up trying to understand why, but now it works :-D

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!