我正在尝试实现一个输出动画图的函数。在
如果我接受简单_动画.py(来自matplotlib示例)作为基础:"""
A simple example of an animated plot
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01) # x-array
line, = ax.plot(x, np.sin(x))
def animate(i):
line.set_ydata(np.sin(x+i/10.0)) # 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, np.arange(1, 200), init_func=init,
interval=25, blit=True)
plt.show()
它有效地工作。在
但是,如果我在函数中关闭此代码(为了提供可更改的参数,并避免对每个可能的参数值执行显式文件):
^{pr2}$
然后调用函数,图形图仍为白色。事实上,它永远不会进入animate函数。在
我知道我漏掉了一些信息,这就是为什么它不起作用。
有人能给我一些提示吗?在
非常感谢你
安德烈