I need to create a figure in a file without displaying it within IPython notebook. I am not clear on the interaction between IPython
and matplotlib.pylab
in this regard. But, when I call pylab.savefig("test.png")
the current figure get's displayed in addition to being saved in test.png
. When automating the creation of a large set of plot files, this is often undesirable. Or in the situation that an intermediate file for external processing by another app is desired.
Not sure if this is a matplotlib
or IPython
notebook question.
Best Answer
This is a matplotlib question, and you can get around this by using a backend that doesn't display to the user, e.g. 'Agg':
EDIT: If you don't want to lose the ability to display plots, turn off Interactive Mode, and only call
plt.show()
when you are ready to display the plots: