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 <mark...@gmail.com> 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
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users