WRJ
WRJ

Reputation: 667

Spyder console turn off interactive matplotlib plotting

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

Upvotes: 6

Views: 2744

Answers (1)

Stop harming Monica
Stop harming Monica

Reputation: 12618

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.

Upvotes: 6

Related Questions