I was trying the first simple animation from this page. I am clearly a beginner at making animations. I paste the code below.
from matplotlib import pyplot as plt
from celluloid import Camera
fig = plt.figure()
camera = Camera(fig)
for i in range(10):
plt.plot([i] * 10)
camera.snap()
animation = camera.animate()
It gives me the following error.
Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.
As far as I can see, animate() has already been assigned a name. Could anyone resolve this issue for me?
To avoid this error (in fact is just a UserWarning
), you have to display or save the animation. At the bottom of your code:
from matplotlib import pyplot as plt
from celluloid import Camera
fig = plt.figure()
camera = Camera(fig)
for i in range(10):
plt.plot([i] * 10)
camera.snap()
animation = camera.animate()
plt.show()
# OR
animation.save('test.mp4')