Filter löschen
Filter löschen

How can I make sure that subplot is displayed in the correct figure during a loop?

1 Ansicht (letzte 30 Tage)
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

Antworten (1)

Star Strider
Star Strider am 31 Mai 2015
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 Kommentar
Image Analyst
Image Analyst am 31 Mai 2015
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.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by