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

조회 수: 9 (최근 30일)
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

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 2월 27일
You could also use a quiver plot.
  댓글 수: 1
Sabrina Wendt
Sabrina Wendt 2013년 2월 27일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by