how to stop continuous pop up of figures
148 views (last 30 days)
Adam Danz on 13 Jan 2020
Edited: Adam Danz on 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')