In a python interactive session the following code is run:
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
how do I let show() not block and not actually show the image, but instead store it in a file?
I can not change the code to plt.savefig('figure.png')
. (There is a very good reason for this, I can explain if interested.)
The way to go seems to be specifying a custom backend renderer but so far no success. Is it possible to take an existing backend renderer and change the show() method to save to a file? (Lets say "figure%d.png" with %d the amount of times show() has been called so far.)
Other suggestions next to a custom backend renderer are welcome as well. In IPython notebook if you execute plt.show(), it manages to take the image and place it beneath the active code block. How's that done?