If I create a file test.py
with the code
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
if __name__ == \'__main
From the animation documentation: "[..] it is critical to keep a reference to the instance object."
So you need to keep the FuncAnimation instance alive by assigning it to a variable.
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
if __name__ == '__main__':
fig = plt.figure()
title = fig.suptitle("Test _")
def anim(i):
title.set_text("Test %d" % i)
plt.plot([0,1], [0,1])
ani = FuncAnimation(fig, anim)
plt.show()
Animation
should be stored internally or not.