Reputation: 715
I am using pylab to generate numerous figures that I would like to save to disk and examine after my script finishes. However my particular python script shows every single figure that is generated and somewhere between the number crunching and the numerous unresponsive figure windows that are opened up my system becomes unresponsive or sluggish at best. Is there a way to prevent the pylab figure windows from popping up during a script? Thanks in advance.
Here is a snippet of code used to generate several figures
...
import pylab as pl
...
# Create the figure (Letter format)
for r, f in enumerate(fif_queue):
fig, ax = pl.subplots(1, 1, figsize=(8, 5.5), dpi=72)
figname = (f[:-4] + '-RAWplot.pdf')
ax.plot(raws[r][0])
ax.axis('tight')
ax.set_xticklabels(['%.0f' % i for x, i in enumerate(np.linspace(start,stop,10))])
ax.set_xlabel('time (s)')
ax.set_ylabel('MEG data (T)')
ax.grid()
fig.savefig(figname, format='pdf')
pl.close('all')
Upvotes: 1
Views: 627
Reputation: 87376
Turn off interactive plotting; insert
pl.ioff()
before your loop. If you want to turn interactive plotting back on when you are done add a
pl.ion()
after your last line.
Upvotes: 6