>>>>> "Steve" == Steve Schmerler <[EMAIL PROTECTED]> writes:
Steve> leau2001 wrote: >> I made some figure in a loop and i want to close after the >> figure show. >> Steve> Not absolutely sure what you mean, but to produce some Steve> plots and save them in a loop I do Steve> f = figure() for i in range(..): plot(...) savefig(...) Steve> f.clf() # clear figure for re-use close(f) Often times what people are looking for is they want to the figure to pop up on the screen, look at it, have it close, and move on. One way to achieve this is to run mpl in interactive mode http://matplotlib.sf.net/interactive.html and then insert a time.sleep or call input("Press any key for next figure: ") If this is what you are doing, threading becomes important. This is discussed on the web page linked above, and your best bet is to either use the tkagg backend or better yet, use ipython in -pylab mode. Something like import sys from pylab import figure, close, show, nx, ion ion() while 1: fig = figure() ax = fig.add_subplot(111) x, y = nx.mlab.rand(2,30) ax.plot(x,y,'o') fig.canvas.draw() k = raw_input("press any key to continue, q to quit: ") if k.lower().startswith('q'): sys.exit() close() show() _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users