MATLAB Answers

AxesToolBar is not Responding for two axes on top of each other.

1 view (last 30 days)
Mehmed Saad
Mehmed Saad on 15 May 2020
Commented: Mehmed Saad on 18 May 2020
Hi,
I am trying to write a code in which a switch button changes the axes on a figure where each axes contains mesh. I am currently doing it by setting the Visible property of axes and its children to off in callback of switch button. My code is below
f =figure;
uicontrol(f,'Style','pushbutton','String','Switch','Callback',@temp)
ax(1) = axes(f);
mesh(ax(1),rand(10,10),'Visible','off'),title('Plot 1')
ax(1).Visible = 'off';
ax(2) = axes(f);
mesh(ax(2),rand(10,10)),title('Plot 2')
function temp(obj,~)
ax = findobj(obj.Parent,'Type','Axes');
for i=1:length(ax)
if(strcmp(ax(i).Visible,'on'))
ax(i).Visible='off';
ax(i).Children.Visible = 'off';
else
ax(i).Visible='on';
ax(i).Children.Visible = 'on';
end
end
end

Initial figure

After Switch is pressed

The problem i am encountering is with the axes Tool bar. For example i select rotate3d. when i rotate Plot 2 it works perfectly, but i try to rotate Plot 1 after switching it is not rotating. (Built in interactions of axes are working though).
Assuming ax(1) is Plot 1 and ax(2) is Plot 2, i tried to set toolbar visibility of ax(2) to off but it is still not working.
Regards,
M.SAAD

Answers (0)

Tags

Products


Release

R2019a

Translated by