logo

... matplot gif.


An image can say a thousand words. But sometimes having a gif can make it just a bit easier. In this series of video's we'll highlight a tool called gif that makes it easy to turn matplotlib plots into gifs.


Episode Notes

Remember that you do need to have gif installed to run this code.

import gif
import numpy as np
import matplotlib.pylab as plt

@gif.frame
def frame(i):
    x = np.linspace(0, 2*np.pi, 100)
    y = np.sin(x)
    plt.plot(x, y)
    plt.scatter([x[i]], [y[i]]);

frames = [frame(i) for i in range(100)]

gif.save(frames, "sine-wave.gif", duration=200)

Feedback? See an issue? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.