LoginSignup
0
1

More than 3 years have passed since last update.

Matplotlib animation

Posted at

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')

mytest.gif

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1