Eric J Ma's Website

Easy `matplotlib` animations

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


I recently stumbled upon a package that makes animations dead simple. Check it out!

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!


Cite this blog post:
@article{
    ericmjl-2020-easy-animations,
    author = {Eric J. Ma},
    title = {Easy `matplotlib` animations},
    year = {2020},
    month = {05},
    day = {26},
    howpublished = {\url{https://ericmjl.github.io}},
    journal = {Eric J. Ma's Blog},
    url = {https://ericmjl.github.io/blog/2020/5/26/easy-matplotlib-animations},
}
  

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 teams that are looking to leverage GenAI for maximum impact. Consider booking a call on Calendly if you're interested!