Skip to content

Instantly share code, notes, and snippets.

@ImportanceOfBeingErnest
Created November 6, 2018 19:05
Show Gist options
  • Save ImportanceOfBeingErnest/f44d5137fa44fa9f5e1833bb022d3eee to your computer and use it in GitHub Desktop.
Save ImportanceOfBeingErnest/f44d5137fa44fa9f5e1833bb022d3eee to your computer and use it in GitHub Desktop.
mwe for saving an animation with pillow
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
numHeatMaps = 2
measurements = [[(i + 1, j + 1, k * 100 + i * 10 + j) for i in range(5) for j in range(5)] for k in range(numHeatMaps)]
fig, ax = plt.subplots()
im = ax.imshow(measurements[0])
def update(i):
im.set_data(measurements[i])
ani = FuncAnimation(fig, update, frames=len(measurements))
ani.save("test.gif", writer="pillow")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment