From: pierre g. <pie...@gm...> - 2008-12-10 23:20:07
|
Hi, I have taken the blit example and modified it such that it runs on my mac. The function is called blit_ex.py. It works well when I paste the code in ipython, but it doesn't when I do "run blit_ex.py" from ipython. I am using EPD Py25 4.1.30001_beta1 and Mac OS 10.5. The error message is: In [1]: run blit_ex.py --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) /Users/pierre/Desktop/blit_ex.py in <module>() 24 canvas.restore_region(background) 25 line.set_ydata(np.sin(x+i/10.)) ---> 26 ax.draw_artist(line) 27 canvas.blit(ax.bbox) 28 /Library/Frameworks/Python.framework/Versions/4.1.30001/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib/axes.pyc in draw_artist(self, a) 1532 data (axis ticks, labels, etc are not updated) 1533 """ -> 1534 assert self._cachedRenderer is not None 1535 a.draw(self._cachedRenderer) 1536 AssertionError: WARNING: Failure executing file: <blit_ex.py> And the code is import matplotlib.pyplot as plt import numpy as np import time plt.figure(1) plt.clf() ax = plt.subplot(111) canvas = ax.figure.canvas # for profiling tstart = time.time() # 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) for i in range(100): canvas.restore_region(background) line.set_ydata(np.sin(x+i/10.)) ax.draw_artist(line) canvas.blit(ax.bbox) Thanks! Pierre |