how to stop continuous pop up of figures

144 vues (au cours des 30 derniers jours)
Manisha Patil
Manisha Patil le 13 Jan 2020
Modifié(e) : Adam Danz le 4 Mai 2020
the figures are continuously popping up, when i clicked the run button.
the file also deleted then too the figures are popping up in 100+ numbers

Réponses (1)

Adam Danz
Adam Danz le 13 Jan 2020
Modifié(e) : Adam Danz le 14 Jan 2020
The figures are being created somehwere in the file or from a function being called from within the file. You'll need to make changes to the code that manages how/when the figures are created.
Idea: set a flag
Since the figures are likely useful, you can set a flag with a default value of FALSE and put each segment of figure-producing code within a conditional statement that only produces the figures when the flag is TRUE. For an example, see this answer. That will require you to find where the figures are being produced. I doubt 100+ figures need to be produced every time a code is run.
Idea: dock all figures
Instead of the figures popping up all over the desktop, they can all be docked by executing this line of code prior to running the file. Note that all subsequent figures will be docked until the settings are set back to normal.
set(0,'DefaultFigureWindowStyle','docked') % 'normal' to un-dock
Alternatively, you can doc specific figures by using
figure(___, 'WindowStyle', 'Docked')
Idea: separate computation from visualization
Code is generally cleaner, more readable, and more efficient when large blocks of computation are separated from visualization. Functions and scripts are meant to be modular. Think of them as a box that receives input and performs a task using those inputs. The data are one product and their visualization is another. I doubt the production of 100+ figures is doing 1 task.
Idea (not recommended): set figure visibility to off
You can set the visibiliy of all subsequent figures to be 'off'. In that case, the figures are still being produced but they are not visible. The benefit is that the code will run more quickly and you won't see the figures. The problem is that you'll have 100+ figures that you (an others) aren't aware of and those invisible figures are consuming memory. This line of code would be run prior to running the script/function.
set(groot,'defaultFigureVisible','off') % 'on' to turn back on.
Alternatively, you can set specific figures by using
figure(___, 'Visible', 'off')
  2 commentaires
Cael Warner
Cael Warner le 4 Mai 2020
In the first case the figure will keep appearing from being called in the loop, and if there are any other figures they may not be viewed for any appreciable amount of time.
If you create a subplot in your figure, you can save the axes using
ax1 = subplot(1,1,1);
plot(ax1,x,y);
When you call plot(ax1,x,y) multiple times in a loop, the figure will stay in the background, and other figures may be viewed independently.
Adam Danz
Adam Danz le 4 Mai 2020
Modifié(e) : Adam Danz le 4 Mai 2020
To create a single axes and store it's handle,
ax = axes();
or
fig = figure();
ax = axes(fig);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by