Eric J Ma's Website

Easy `matplotlib` animations

written by Eric J. Ma on 2020-05-26 | tags: matplotlib python data visualization animation


Recently, celluloid caught my eye: it's a package that lets you create matplotlib animations easily!

If you need a dead-simple example to convince you to check it out, here's one lifted straight from the repository:

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()

But seriously though, if you use the workhorse Python drawing package matplotlib for anything, this package can be considered to be one of those "great tricks to have" in your bag!


I send out a newsletter with tips and tools for data scientists. Come check it out at Substack.

If you would like to sponsor the coffee that goes into making my posts, please consider GitHub Sponsors!

Finally, I do free 30-minute GenAI strategy calls for organizations who are seeking guidance on how to best leverage this technology. Consider booking a call on Calendly if you're interested!