matplotlib で sin波のアニメーションを作った
-
ax.plot()
をimg
で拾える -
ax.set_prop_cycle(None)
で色を固定できる -
'imagemagick'
はお手持ちの環境で -
repeat=False
がうまく動かないのは疑問
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as mpani
x = 2*np.pi* np.arange(50)/50
fig = plt.figure()
ax = fig.add_subplot(111)
imgs = []
for dx in x:
ax.set_prop_cycle(None)
img = ax.plot(x, np.sin(x+dx))
imgs.append(img)
ani = mpani.ArtistAnimation(fig, imgs, interval=100, blit=True, repeat=False)
ani.save('mytest.gif', 'imagemagick')