|
From: Mark B. <ma...@gm...> - 2014-04-23 09:44:30
|
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 |