Oops; my sentence should have read "is *not* derived from an artist".
On Sun, Nov 13, 2011 at 1:24 PM, Benjamin Root <ben.r...@ou.edu> wrote: > > > On Sunday, November 13, 2011, Daniel Hyams <dhy...@gmail.com> wrote: >> This looks like a bug in matplotlib to me; I get the same thing. >> >> The basic issue is that QuadContourSet is derived from an artist, and >> so does not have all of the artist methods; the animation framework >> depends on the things that it is animating being artists. >> >> The following monkey patch fixes it in the example script (obviously, >> it does not fix the underlying problem; for QuadContourSet to be >> usable in this context, it needs to obey the artist interface). >> Hopefully, it will be enough to get you up and running. Just add the >> four lines between contour call and the appending of the output of >> contour() into the list "ims", and also put an "import types" at the >> top. >> >> >> #!/usr/bin/env python >> """ >> An animated image >> """ >> import numpy as np >> import matplotlib.pyplot as plt >> import matplotlib.animation as animation >> import types >> fig = plt.figure() >> def f(x, y): >> return np.sin(x) + np.cos(y) >> x = np.linspace(0, 2 * np.pi, 120) >> y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1) >> # ims is a list of lists, each row is a list of artists to draw in the >> # current frame; here we are just animating one artist, the image, in >> # each frame >> ims = [] >> for i in range(60): >> x += np.pi / 15. >> y += np.pi / 20. >> im = plt.contour(f(x, y)) >> def setvisible(self,vis): >> for c in self.collections: c.set_visible(vis) >> im.set_visible = types.MethodType(setvisible,im,None) >> im.axes = plt.gca() >> ims.append([im]) >> ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True, >> repeat_delay=1000) >> ani.save('dynamic_images.mp4') >> >> plt.show() >> > > Technically speaking, it is derived from ScalarMappable, not Artist. It is > counter-intuitive, though. > > Ben Root -- Daniel Hyams dhy...@gmail.com ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users