From: John H. <jd...@gm...> - 2008-12-11 02:41:46
|
On Wed, Dec 10, 2008 at 5:20 PM, pierre garrigues < pie...@gm...> wrote: > > # create the initial line > x = np.linspace(-3, 3, 1000) > line, = plt.plot(x, np.sin(x), animated=True) > > # save the clean slate background -- everything but the animated line > # is drawn and saved in the pixel buffer background > background = canvas.copy_from_bbox(ax.bbox) > It looks to me that you need to force a figure draw *before* doing copy_from_bbox. Eg:: fig.canvas.draw() background = canvas.copy_from_bbox(ax.bbox) The reason you are seeing a difference between ipython "run" and ipython copy-and-paste is that in "run" mode ipython turns interactive drawing off (for details see http://matplotlib.sourceforge.net/users/shell.html) so the draw event is never called, and the cached renderer, which is triggering your exception, is never set. This is speculation, as I haven't tested, so please answer back if this fixes your problem and if so I will update the matplotlib animation recipe which also suffers from this problem (which is not exposed unless you are running in interactive mode, which you are). It is on my list of things to do to write a proper animation chapter for the user's guide.... JDH |