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
댓글 수: 0
채택된 답변
Sean de Wolski
2013년 2월 27일
http://www.mathworks.com/matlabcentral/fileexchange/32536-annotation-pinned-to-axes Seems to be well liked.
You could also use a quiver plot.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!