Find all Text in Tiledlayout

4 views (last 30 days)
Frantisek Gaspar
Frantisek Gaspar on 13 Apr 2022
Using function findall I tried to get handles of all Text objects in a figure. For most Text objects findall(gcf(), "Type", "text") works BUT...
In tilledlayout there are Text objects (Title, XLabel, YLabel) which are not your every day Text objects but they are 'matlab.graphics.layout.Text' which differ from the usual 'matlab.graphics.primitive.Text'. I believe this is the reason why above-mentioned findall does not return these layout.Text object handles.
Is there a general approach how to obtain REALY all object handles that can handle these special cases?
Is there at least a way to get all 'matlab.graphics.layout.Text' in a figure?

Answers (1)

Bhanu Prakash Reddy
Bhanu Prakash Reddy on 12 Oct 2023
Hi Frantisek,
As per my understanding, you want to obtain all the 'matlab.graphics.layout.Text’ objects in a figure.
To obtains those objects, you can use the ‘findobj’ function with the ‘Type’ property in MATLAB. For example, to capture all the 'matlab.graphics.layout.Text’ objects in a figure, you can use the ‘findobj’ function as follows:
% Find all 'matlab.graphics.layout.Text' objects in the figure
TextObjs = findobj(gcf, 'Type', 'matlab.graphics.layout.Text');
% Display the handles of the layout.Text objects
disp(TextObjs);
As the function ‘findobj’ searches the objects based on their properties, you can further refine the search by adding additional properties.
For more information the ‘findobj’ function, please refer to the following documentation:

Categories

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

Products

Community Treasure Hunt

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

Start Hunting!