-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Labels
API: consistencyDifficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesstatus: needs comment/discussionneeds consensus on next stepneeds consensus on next steptopic: animation
Milestone
Description
Unlike other plotting operations, if you create an animation and do not store it in a persistent variable, it will fail.
So, for example,
import matplotlib.pyplot as plt
from matplotlib import animation
fig = plt.figure()
def animate(i):
# ... do something here
anim = animation.FuncAnimation(fig, animate)
plt.show()
will work, but changing the final lines to
animation.FuncAnimation(fig, animate)
plt.show()
(i.e. not creating a variable to store the animation) leads to a quiet failure.
I think the problem is because the figure does not store a reference to the animation object, python's garbage collection removes it if it is not explicitly stored.
Probably the best way to address this would be to add an animation
attribute to the Figure
class, such that any animation will store a pointer to itself in its associated figure.
I think this is a pretty easy fix, but I'm just wondering if there are any other details to be aware of when adding something like this.
GeorgySk
Metadata
Metadata
Assignees
Labels
API: consistencyDifficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesstatus: needs comment/discussionneeds consensus on next stepneeds consensus on next steptopic: animation