Finding handles to figure text

28 views (last 30 days)
Matt J
Matt J on 13 May 2020
Edited: Rik on 15 May 2020
I am attempting to use findobj to retrieve text objects in a plot. For some reason, this fails (R2018a,b). In the following example, I expect to retrieve handles to the axis labels, but it doesn't work.
>> plot(1:5); xlabel X; ylabel Y
>> H=findobj(gcf, '-property','Interpreter')
H =
0×0 empty GraphicsPlaceholder array.
No other property search seems to work either:
>> H=findobj(gcf, '-property','String')
H =
0×0 empty GraphicsPlaceholder array.
>> H=findobj(gcf, 'Type','Text')
H =
0×0 empty GraphicsPlaceholder array.
Does anyone know why findobj fails when used this way?

Accepted Answer

Rik
Rik on 13 May 2020
Edited: Rik on 15 May 2020
The doc suggests the HandleVisibility property should be on to be found. The code below returns off on my copy of R2020a. The R2018a doc also contains this statement.
plot(1:5); xlabel X; ylabel Y
H=findobj(gcf);
H(1).Children.XLabel.HandleVisibility
You can use findall instead
  1 Comment
Matt J
Matt J on 15 May 2020
That is interesting. I wonder what motivated the decision to make text annotation handles invisible...?

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!