How can I make sure that subplot is displayed in the correct figure during a loop?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a loop in which I create subplots in figure(1) and three other figures with no subplots. After some iterations the second subplot (e.g. subplot(6,2,2)) disappear from figure(1) and is displayed in another figure that is also created in my loop. Does anyone can help? Thanks
0 件のコメント
回答 (1 件)
Star Strider
2015 年 5 月 31 日
We don’t have your code, so I can only guess. To be certain that subsequent plots do not plot in the currently open figure window (the default behaviour), create new specific figure windows for each figure:
figure(1)
subplot(6,2,1)
plot( ... )
... and so forth ...
figure(2)
plot( ... )
figure(3)
plot( ... )
1 件のコメント
Image Analyst
2015 年 5 月 31 日
To explain further, this will create new figures 1, 2, and 3, only if those figures do not exist already. So if these are in a loop, figure(1) just switches focus to figure #1 - it does not create another figure. Doing this should make sure that your subplot occurs only on figure 1 and not on another figure. Somehow focus got switched to the other figure by the time subplot() came along - perhaps you clicked on that figure which might cause the switch in the active/current figure.
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!