自从更新到matplotlib 1.5.0,
matplotlib.animation.FuncAnimation(fig, func, init_func=func,
frames=frames,
interval=1100,repeat_delay=2000,
blit=True)
结果是
AttributeError: ‘NoneType’ object has no attribute ‘set_animated’
在第1134行的matplotlib / animation.py中,是
TimedAnimation.__init__(self, fig, **kwargs)
我需要设置blit = False才能继续而不会出错.
无论我如何更改fig,func等的值,都会发生这种情况,无论如何,这些都在1.5.0之前都能正常工作.
1.5.0是否有变化导致这种情况?有什么我可以继续使用blit = True吗?
解决方法:
在我的具体情况中,我在多个轴上设置了几条线.当我设置blit = True时,我看到了同样的错误.修复是从我的animate()函数更改return语句 – 在我从模板中抓取的原始函数中,函数看起来像
def animate(i):
...
return lines,
需要改为
def animate(i):
...
return lines # no comma
blit参数必须告诉某些东西将动画作为艺术家返回的每个元素都用set_animated方法处理 – 逗号会添加一个额外的层次结构层,即列表中的列表而不是艺术家列表.
标签:python,python-2-7,matplotlib
来源: https://codeday.me/bug/20190711/1432896.html