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.

49 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

dpb
dpb am 17 Okt. 2022
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 Kommentare
dpb
dpb am 17 Okt. 2022
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by