【python】动画----Matplotlib 模块学习系列(二)
主要注意点:
FuncAnimation 参数
- figure : plt.figure()
- func : 动画函数 参数
- frames : 帧数
- init_func 初始化函数
- interval : 间隔毫秒
- blit : true | false
from matplotlib import pyplot as plt
from matplotlib import animation
import numpy as np
fig = plt.figure(num=4, figsize=(4,3))
x = np.arange(0, 2*np.pi, 0.01)
line, = plt.plot(x, np.sin(x), color='red')
def play(i):
line.set_ydata(np.sin(x + i/10))
return line,
def init():
line.set_ydata(np.sin(x))
return line,
anim = animation.FuncAnimation(fig=fig, func=play, frames=360, init_func=init, interval=30, blit=False)
plt.show()