为什么从 1.5.0 开始我不能在调用 matplotlib.animation.FuncAnimation 时设置 blit=True ?

oro*_*ome 5 python matplotlib python-2.7

自从更新到 matplotlib 1.5.0 以来,

matplotlib.animation.FuncAnimation(fig, func, init_func=func,
                                   frames=frames, 
                                   interval=1100,repeat_delay=2000, 
                                   blit=True)
Run Code Online (Sandbox Code Playgroud)

结果是

AttributeError:“NoneType”对象没有属性“set_animated”

在 matplotlib/animation.py 的第 1134 行,即

TimedAnimation.__init__(self, fig, **kwargs)
Run Code Online (Sandbox Code Playgroud)

我需要进行设置blit=False才能继续而不会出现错误。

无论我如何更改 、 等的值,都会发生这种情况figfunc无论如何,这些值在 1.5.0 之前都工作正常。

1.5.0 中是否有更改导致此问题?我可以继续做些什么吗blit=True

Red*_*nda 2

在我的具体情况下,我对分布在多个轴上的几条线进行了动画处理。当我设置时,blit=True我看到了同样的错误。解决方法是更改return​​我的animate()函数中的语句 - 在我从模板中获取的原始版本中,该函数看起来像

def animate(i):
...
return lines,
Run Code Online (Sandbox Code Playgroud)

需要改为

def animate(i):
...
return lines  # no comma
Run Code Online (Sandbox Code Playgroud)

blit 参数必须告诉某些东西,将 animate 返回的每个元素视为具有该set_animated方法的艺术家 - 逗号会添加额外的层次结构层,即列表中的列表而不是艺术家列表。