how to surpress figure pop out within interactive ipython shell?

Dear matplotlib users,

How can I surpress the figure pop out when I make plot within the ipython interactive shell?
suppose I make a figure first and I want to save it:

fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot(np.arange(10))
fig.savefig(‘fig1.png’)
###actually above is only an example and usually I use loop to make many figures.

then I want to check another plot:

plt.plot(np.arange(10))
plt.show()

The problem is, when I use plt.show() to check the recently made plot, all the figures I saved for the last session will pop out and I have to click on the close icon to close them one by one,
which can be really annoying…

any idea would be greatly appreciated!

cheers,

Chao

···


Chao YUE
Laboratoire des Sciences du Climat et de l’Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex

Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16


Try adding ‘plt.close(fig)’ after you save the figure, or just plt.close() if you want to close everything.

···

On Thu, Dec 15, 2011 at 12:33 PM, Chao YUE <chaoyuejoy@…985…> wrote:

Dear matplotlib users,

How can I surpress the figure pop out when I make plot within the ipython interactive shell?
suppose I make a figure first and I want to save it:

fig=plt.figure()
ax=fig.add_subplot(111)

ax.plot(np.arange(10))
fig.savefig(‘fig1.png’)
###actually above is only an example and usually I use loop to make many figures.