Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Star Strider
Star Strider il 31 Mag 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 Commento
Image Analyst
Image Analyst il 31 Mag 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.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by