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

fig, axes = plt.subplots(2)
camera = Camera(fig)
t = np.linspace(0, 2.0*np.pi, 128, endpoint=False)
for i in t:
    axes[0].plot(t, np.sin(t + i), color='blue')
    axes[1].plot(t, np.sin(t - i), color='blue')
    camera.snap()

animation = camera.animate()
animation.save('ex354.gif', writer='PillowWriter', fps=24)

Discover more from Tips and Hints for Aerospace Engineers

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

Continue reading