加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 为什么我不能在1.5.0之后调用matplotlib.animation.Fu

发布时间:2020-12-20 13:08:29 所属栏目:Python 来源:网络整理
导读:自从更新到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行的matplo
自从更新到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方法处理 – 逗号会添加一个额外的层次结构层,即列表中的列表而不是艺术家列表.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读