# pip install celluloid
#%matplotlib qt
from matplotlib import pyplot as plt
from celluloid import Camera
import numpy as np

fig = plt.figure()
camera = Camera(fig)
t = np.linspace(0, 2 * np.pi, 128, endpoint=False)
for i in range(0,41) :
    p=plt.plot(t, i*np.sin(t))
    plt.legend(p, [f'line {i}'])
    camera.snap()
animation = camera.animate()
animation.save('ex356.gif', writer='PillowWriter', fps=12)

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading