matplotlib 的 animation子模块的 FuncAnimation()函数支持动画功能,可用于动态绘图。
例子1:
?...ax = plt.subplots()
xdata, ydata = [], []
ln, = plt.plot([], [], 'ro', animated=True)
ax.set_title("动画基本案例...),
init_func=init, blit=True, interval=20)
#ani.save('sin_dot.gif', fps=20) #可保存动画...repeat 为bool型,动画结束后是否重复,默认False。
blit 为bool型,是否用blitting技术优化绘图,默认False。
例子2:
?...as plt
import matplotlib.animation as animation
def data_gen(t=0):#生成器
for i in range(800):