From: John H. <jdh...@ac...> - 2003-12-15 21:07:06
|
>>>>> "Christopher" == Christopher Fonnesbeck <ch...@fo...> writes: Christopher> code for some reason, but instead hangs. When I try Christopher> and close the plot manually, it terminates the python Christopher> code. How can I get matplotlib to produce a new plot Christopher> each time it is called, moving on after each plot is Christopher> produced, displayed and saved to file. Here is a Christopher> sample function from my code: For the GTK backend, there is another solution. The call to ShowOn().set(1) tells matplotlib to execute the commands as they are issued, which was originally designed for people using matplotlib from the python shell but also applies to your case, where you want to generate a bunch of figures one at a time import matplotlib matplotlib.use('GTK') from matplotlib.matlab import * from matplotlib.backends.backend_gtk import ShowOn ShowOn().set(1) t = arange(0.0, 3.0, 0.01) for i in range(1,10): figure(1) s = sin(2*pi*i*t) plot(t,s) savefig('plot%02d' % i) close(1) *Note there is no call to show at the end* The same trick *does not* currently work with the WX backend, though perhaps Jeremy can take a look at it and determine why not. Somehow the call the ShowOn().set(1) seems to screw it up. We'll look into it... JDH |