how to make arrows
12 ビュー (過去 30 日間)
古いコメントを表示
hi there! here is my question. I am using text command to place some text to specific points [x1,y1]=ginput(1); text(x1,y1,'P'); Now, is it possible to draw an arrow from that point (named P) down to x1 ? Can you please tell me how to do that ? Thanks. PS i don't want to make it manually, it has to be done automatically.
0 件のコメント
採用された回答
Arnaud Miege
2011 年 5 月 18 日
You can use the annotation function as suggested by Matt. As pointed out, the coordinates need to be normalized. There's a nice utility function on the FEX that does that:
HTH,
Arnaud
0 件のコメント
その他の回答 (2 件)
Matt Fig
2011 年 5 月 17 日
As an alternative, here is a way to do it using the ANNOTATION function. Run the code and click where you would like the text to appear (somewhere in the upper middle), then click again near the parabola.
figure('units','norm')
x = -2:.1:2;
axes('units','norm')
plot(x,x.^2); % Plot a parabola
% The first point will have text, second the arrowhead...
[x1,y1] = ginput(2); % Get two points from user.
A = annotation('textarrow','units','norm','string','Parabola');
% Next we need to transform the GINPUT values to figure units.
XL = get(gca,{'xlim','ylim','pos'});
[XL,YL,P] = deal(XL{:});
Ax = P(3)*(x1-XL(1))/diff(XL)+P(1);
Ay = P(4)*(y1-YL(1))/diff(YL)+P(2);
set(A,'x',Ax,'y',Ay) % Set the arrow in the correct position.
4 件のコメント
Matt Fig
2011 年 5 月 17 日
Good idea Sean de, I will try to get it done in the next day or two.
@Kelly: Right on, I'll look for yours too!
参考
カテゴリ
Help Center および File Exchange で Data Exploration についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!