How to switch between one plot and two subplots on a GUI?
Show older comments
Hi all,
I created a GUI, using GUIDE, and in it I placed an axes. I have no problem to reach this axes and plot whatever on it. In some cases I want to use two subplots where this axes is located. I tried it and the original axes was deleted while two others, one for each subplot, were created. Now I can't return to the one axes configuration because it is gone.
What is the best approach to be able to switch between one plot and two subplots at the same place where the original axes is located?
Thanks,
Alon
Answers (2)
Jan
on 18 Dec 2016
SubPlotH = [subplot(2,1,1), subplot(2,1,2)];
AxesH = axes;
for k = 1:10
if rem(k, 2) == 1
set(SubPlotH, 'Visible', 'off');
set(AxesH, 'Visible', 'on');
else
set(SubPlotH, 'Visible', 'on');
set(AxesH, 'Visible', 'off');
end
pause(1);
end
3 Comments
Alon Rozen
on 19 Dec 2016
Jan
on 19 Dec 2016
No, the axes object is not deleted, "when you plot on the subplots". This deleting must have a cause. So please use the debugger at first to find the reason of the deleting, or at least the line, where it is deleted. Then post the relevant code.
Alon Rozen
on 23 Jan 2017
Walter Roberson
on 23 Jan 2017
0 votes
subplot always deletes any axes that it overlaps. You need to axes() up new axes. Or, design three axes in GUIDE and hide what is not in use, never calling subplot.
1 Comment
Alon Rozen
on 24 Jan 2017
Categories
Find more on Subplots 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!