Why findobj cannot find a TexBox (annotation) object?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kouichi C. Nakamura
am 4 Dez. 2020
Kommentiert: Kouichi C. Nakamura
am 4 Dez. 2020
While HandleVisibility property of a TextBox object is 'on' by default,
fig = figure
txb = annotation('textbox',[0.5 0.5 0.5 0.5],'String','bar hoo')
class(txb)
ans =
'matlab.graphics.shape.TextBox'
txb.Type %
ans = 'textboxshape'
txb.HandleVisibility
ans = 'on'
findobj cannot find this txb.
findobj(fig,'Type','textboxshape')
ans =
Why is this and how can I find this txb?
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 4 Dez. 2020
Bearbeitet: Cris LaPierre
am 4 Dez. 2020
Try using the object handle (txb) directly.
plot(1:10)
str = 'Straight Line Plot from 1 to 10';
txb = annotation('textbox',[.2 .5 .3 .3],'String',str,'FitBoxToText','on');
% Use object handle
findobj(txb)
If you want to instead find the annotation without using the object handle, use findall instead.
findall(gcf,'Type','textboxshape')
4 Kommentare
Cris LaPierre
am 4 Dez. 2020
Good point. The underlying issue was handle visibility, as you pointed out below. I'll update my response to remove any confusion.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Graphics Object Identification 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!