How to use text command with text left of xline and \rightarrow pointing to xline? Easy to place text right of xline with \leftarrow pointing from beginning of text to xline.

31 次查看(过去 30 天)
plot(1:5,1:5);hold on;xline(2);
% Next line works as intended if want text right of xline with arrow pointing left to xline
text(2,1.5,'\leftarrow sample text right of xline, arrow points at xline')
% How to do similar, but text left of xline and arrow pointing right from text to xline?
% Next line doesn't do what is desired
text(2,2.5,'\rightarrow arrow pointed from xline to the right where this text is')
% Next line would work if x coordinate of text was corect amount less than xline value
text(2,3.5,'text begins just right of xline, arrow at end of text points right \rightarrow')
Also open to commands) other than text which would accomplish this.

采纳的回答

dpb
dpb 2022-10-17
You could adjust the starting point to move the prepended right arrow where want it, but don't fight it; just put the two pieces on separately. I left an extra space in front of the text so wouldn't be right on the line itself; suit your purposes in that regards.
plot(1:5,1:5);hold on;xline(2);
text(2,3.5,'\rightarrow','horizontalalignment','right')
text(2,3.5,' text begins just right of xline')
  3 个评论
dpb
dpb 2022-10-17
Well, why didn't you say so...the answer is the same -- use the 'HorizonatalAlignment','right' property to put the right end of the text at the marker location...
plot(1:5,1:5);hold on;xline(4);
text(4,3.5,' text ends just before xline \rightarrow','horizontalalignment','right')
NOTA BENE: you'll have to find the intersection of the two lines to point the arrow precisely at that location.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by