小编Don*_*Don的帖子

关于matplotlib.animation.FuncAnimation的args

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()
ax = fig.add_subplot(111)

x = np.arange(0, 2*np.pi, 0.01)        # x-array
i=1
line, = ax.plot(x, np.sin(x))

def animate():
    i= i+2
    x=x[1:] + [i]
    line.set_ydata(np.sin(x))  # update the data
    return line,

#Init only required for blitting to give a clean slate.
def init():
    line.set_ydata(np.ma.array(x, mask=True))
    return line,

ani = animation.FuncAnimation(fig, animate, init_func=init,
    interval=25, blit=True)
plt.show()
Run Code Online (Sandbox Code Playgroud)

我得到这样的错误:animate()不接受任何参数(给定1个)......很困惑.我甚至没有给回调函数一个arg.有没有我错过的东西?

谢谢.

python animation matplotlib

3
推荐指数
1
解决办法
8022
查看次数

标签 统计

animation ×1

matplotlib ×1

python ×1