|
From: Mark B. <ma...@gm...> - 2014-04-23 14:08:15
|
I thought about that. I even thought about changing the initial color to white or radius to zero. But I am thinking this is a bug. When blitting, whatever is created with the init function is not removed. That is why lines that are animated initially have no data. For a Patch object this is a bit harder, as it needs something to begin with. It seems that this used to work in a previous version. Should I file a bug report? Mark On Wed, Apr 23, 2014 at 3:34 PM, Raymond Smith <sm...@mi...> wrote: > Hi Mark, > > I can't say this is the 'proper' solution or the correct interpretation, > but it should work. > > I think when blitting that the init function serves as a something of a > "background" for the rest of the animation. So try changing > > > def init(): > *patch.center = (5, 5)* > ax.add_patch(patch) > return patch, > > to > > def init(): > *patch.center = (5, -5)* > ax.add_patch(patch) > return patch, > > Cheers, > Ray > > > On Wed, Apr 23, 2014 at 5:44 AM, Mark Bakker <ma...@gm...> wrote: > >> Hello list, >> >> I am trying to animate a patch. The animation should show a circle >> orbiting around a point. I took the code from >> http://nickcharlton.net/posts/drawing-animating-shapes-matplotlib.html >> >> Problem is that when I run the code, the animation doesn't remove the >> initial position of the circle (blit is True) while it works correctly on >> the website referenced above. >> >> Does anybody else see this behavior? Here's the code: >> >> import numpy as np >> from matplotlib import pyplot as plt >> from matplotlib import animation >> >> fig = plt.figure() >> fig.set_dpi(100) >> fig.set_size_inches(7, 6.5) >> >> ax = plt.axes(xlim=(0, 10), ylim=(0, 10)) >> patch = plt.Circle((5, -5), 0.75, fc='y') >> >> def init(): >> patch.center = (5, 5) >> ax.add_patch(patch) >> return patch, >> >> def animate(i): >> x, y = patch.center >> x = 5 + 3 * np.sin(np.radians(i)) >> y = 5 + 3 * np.cos(np.radians(i)) >> patch.center = (x, y) >> return patch, >> >> anim = animation.FuncAnimation(fig, animate, >> init_func=init, >> frames=360, >> interval=20, >> blit=True) >> >> plt.show() >> >> Thanks, Mark >> >> >> ------------------------------------------------------------------------------ >> Start Your Social Network Today - Download eXo Platform >> Build your Enterprise Intranet with eXo Platform Software >> Java Based Open Source Intranet - Social, Extensible, Cloud Ready >> Get Started Now And Turn Your Intranet Into A Collaboration Platform >> http://p.sf.net/sfu/ExoPlatform >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > |