How to address the children of an axes (GUI)?

7 views (last 30 days)
Hello together,
I want to address the children of an axes in another function of my GUI without using findobj. A radiobutton should allow the user to switch between different views of the axes to set texts, lines, groups, ... into noshow/show. Therefore I assigned special tags to the children, but until yet I haven't get it out how to address them. Here you can see the code including findobj:
function rb_ansicht_re_Callback(hObject, eventdata, handles)
global jj
childs=allchild(handles.axes_delta_s);
switch jj
case 2
set(findobj(childs, 'Tag','h_delta_s_1'), 'Visible', 'off')
set(findobj(childs, 'Tag','h_delta_s_2'), 'Visible', 'on')
set(findobj(childs, 'Tag','h_delta_s_k_1'), 'Visible', 'off')
set(findobj(childs, 'Tag','h_delta_s_k_2'), 'Visible', 'on')
set(findobj(childs, 'Tag','h_fi_fl_1'), 'Visible', 'off')
set(findobj(childs, 'Tag','h_fi_fl_2'), 'Visible', 'on')
case 1
% do nothing
end
For suggestions I would be very grateful :-).
With best regards Gina

Accepted Answer

Adam
Adam on 14 Aug 2017
Edited: Adam on 14 Aug 2017
I assume, from the callback syntax, that this is a GUIDE GUI. If so then all your GUI components are stored on the handles structure as fields whose names are the tags that you use in the findobj command so:
handles.h_delta_s_1.Visible = 'off';
etc, should work fine. Or if you are in an older version of Matlab
set( handles.h_delta_s_1, 'Visible', 'off' )
Also don't use global variables. Just dropping jj in from goodness knows where is bad programming practice. If this is your radiobutton then access it also via handles and its tag.
  3 Comments
Adam
Adam on 14 Aug 2017
Ah, yes, I misinterpreted what was being retrieved by the findobj.
When you first plot things on the axes you should store the handle of the object e.g.
handles.h_delta_s_1 = plot( handles.axes_delta_s,... );
guidata( hObject, handles )
then in any other callback you can refer to
handles.h_delta_s_1.Visible = 'off';

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!