matplotlib.animation — Matplotlib 3.5.1 documentation
matplotlib.org › stable › apiThe animation is advanced by a timer (typically from the host GUI framework) which the Animation object holds the only reference to. If you do not hold a reference to the Animation object, it (and hence the timers), will be garbage collected which will stop the animation. To save an animation to disk use Animation.save or Animation.to_html5_video.