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!