How to switch between one plot and two subplots on a GUI?

12 ビュー (過去 30 日間)
Alon Rozen
Alon Rozen 2016 年 12 月 18 日
コメント済み: Alon Rozen 2017 年 1 月 24 日
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

回答 (2 件)

Jan
Jan 2016 年 12 月 18 日
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 件のコメント
Jan
Jan 2016 年 12 月 19 日
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
Alon Rozen 2017 年 1 月 23 日
Hi Jan,
I am back to this problem: Suppose the axes is kept in the 'handle' of the GUI as 'handles.My_Axes', and I have a function named 'Create_Subplots' to create two subplots instead.
After using:
H = handles.My_Axes;
Create_Subplots(H);
inside 'Create_Subplot' I have the code:
function Create_Sublpot(H)
set(H,'Visible','off');
H1 = subplot(1,2,1);
...
end
Now I put a break point on the line that create the subplot H1. before this line H is still an existing axes. After executing this line i get for H:
H: 1x1 matlab.graphics.axis.Axes = handle to deleted Axes
How can I avoid this?
Alon

サインインしてコメントする。


Walter Roberson
Walter Roberson 2017 年 1 月 23 日
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 件のコメント
Alon Rozen
Alon Rozen 2017 年 1 月 24 日
Thanks, Checking both ideas. Alon

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by