Calmcode - matplot gif: gif

Gif

1 2 3 4 5

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)