# The annotation​('textarro​w',...) does not go out of a plot

9 Ansichten (letzte 30 Tage)
Sim am 30 Mai 2023
Kommentiert: Sim am 30 Mai 2023
How to place an annotation('textarrow',...) out of a plot?
hf = figure;
ax = subplot(3,3,5);
hold on
scatter(0:3,0:3,[],'filled','Clipping', 'off')
plot(0:3,0:3,'Clipping', 'off')
hold off
axis equal
axis(ax, [0 2 0 2]);
% My attempt
ha = annotation('textarrow','String','arrow text');
ha.Parent = hf.CurrentAxes;
ha.X = [-2 1];
ha.Y = [1 0];
By using these coordinates:
ha.X = [-2 1];
ha.Y = [1 0];
we can see that the arrow does not go out of the plot. How to show the entire arrow ?
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Sim am 30 Mai 2023
I found this solution. In case you know something better, please let me know!
hf = figure;
ax = subplot(3,3,5);
hold on
scatter(0:3,0:3,[],'filled','Clipping', 'off')
plot(0:3,0:3,'Clipping', 'off')
hold off
axis equal
axis(ax, [0 2 0 2]);
ha = annotation('textarrow','String','arrow text');
ha.Parent = hf.CurrentAxes;
ha.X = [-2 1];
ha.Y = [1 0];
set(get(hf,'children'),'clipping','off')
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Sim am 30 Mai 2023
@VBBV thanks a lot for your comment! I tried what you suggested, but with those coordinates I cannot use the same units as in my graph.... Indeed the coordinates you used are not the same as the units/numbers of the plot:
x = [0.3 0.5];
y = [0.9 0.5];
Right?

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Annotations finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by