1つの方法は、matplotlibライブラリのアニメーション機能を使用することです。注意すべき
#!/usr/bin/env python
"""
An animated image
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
def f(x, y):
return np.sin(x) + np.cos(y)
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
fig = plt.figure()
im = plt.imshow(f(x, y))
def updatefig(*args):
global x,y
x += np.pi/15.
y += np.pi/20.
im.set_array(f(x,y))
return im,
ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)
plt.show()
いくつかである:ここでonline documentationから貼り付けた例コピーが/ある
updatefig
関数でnumpyのアレイ
- 使用
im.set_array
(に変換するように各画像)次の画像をロードする