Skip to content
Advertisement

Python: Add dynamic text in Matplotlib animation

I made an animation from the list of images saved as numpy arrays. Then I want to add a text onto the animation like like a subtitle whose text changes for each frame but placing plt.text(some_string) only adds the string at the first iteration and it does not work if I change the passed string in the loop. Below is my attempt. Please note HTML is just for Jupyter Lab.

JavaScript

Advertisement

Answer

You have also to add the text object to the list of artists for each frame:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement