6
votes

I'm doing some plotting using matplotlib in the Spyder GUI. I just want these figures to be made quietly in the background and save to a file path. I'm running my scripts from the console and while the figures get made and saved fine, I can't stop them all popping up in their own little windows (there are about 240 graphs so clearly this is causing memory issues).

I have scattered the command plt.ioff() generously throughout the script but it doesn't seem to help

Any ideas? Cheers

1
Can you remove plt.show() statement? - mbednarski
There never was a plt.show() statement, that's why I'm so confused - WRJ

1 Answers

5
votes

Figures should not be popping up if you use a non-interactive backend. Put this at the very beginning of the script:

import matplotlib as mpl
mpl.use('Agg')

You might run into memory issues anyway if you create many figures without closing them.