Ask Your Question

Revision history [back]

(referencing @kcrisman 's answer) I think it is maybe better not to import pylab into the global namespace, so just import pylab. To reset the plot, so to speak, you should call pylab.close() (or just close() if you import *) like this:

import pylab
pylab.imshow([[1,0],[0,1]])
pylab.savefig('plot1.png')
pylab.close()
pylab.imshow([[1,2],[0,1]])
pylab.savefig('plot2.png')