AttributeError:“模块"对象没有属性"to_rgba" [英] AttributeError: 'module' object has no attribute 'to_rgba'

查看:54
本文介绍了AttributeError:“模块"对象没有属性"to_rgba"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 matplotlib.pyplot 显示图像时出错

I got error when I used matplotlib.pyplot to show image

      5 plt.ylim(-5,6)
      6 plt.title('Question 1(c): sample cluster data (10,000 points per cluster)')
----> 7 plt.show()

C:\Users\yashi\Anaconda3\envs\CSC411\lib\site-packages\matplotlib\pyplot.py in show(*args, **kw)
    242     In non-interactive mode, display all figures and block until
    243     the figures have been closed; in interactive mode it has no
--> 244     effect unless figures were created prior to a change from
    245     non-interactive to interactive mode (not recommended).  In
    246     that case it displays the figures but does not block.

C:\Users\yashi\Anaconda3\envs\CSC411\lib\site-packages\ipykernel\pylab\backend_inline.pyc in show(close, block)
     37             display(
     38                 figure_manager.canvas.figure,
---> 39                 metadata=_fetch_figure_metadata(figure_manager.canvas.figure)
     40             )
     41     finally:

C:\Users\yashi\Anaconda3\envs\CSC411\lib\site-packages\ipykernel\pylab\backend_inline.pyc in _fetch_figure_metadata(fig)
    172     """Get some metadata to help with displaying a figure."""
    173     # determine if a background is needed for legibility
--> 174     if _is_transparent(fig.get_facecolor()):
    175         # the background is transparent
    176         ticksLight = _is_light([label.get_color()

C:\Users\yashi\Anaconda3\envs\CSC411\lib\site-packages\ipykernel\pylab\backend_inline.pyc in _is_transparent(color)
    193 def _is_transparent(color):
    194     """Determine transparency from alpha."""
--> 195     rgba = colors.to_rgba(color)
    196     return rgba[3] < .5

AttributeError: 'module' object has no attribute 'to_rgba'

根据帖子

我将matplotlib更新为2.23,但仍然无法正常工作.我该如何解决?

I updated matplotlib to 2.23 but it still doesn't work. How can I fix it?

推荐答案

我也遇到了这种情况,这是由ipykernel版本引起的.我将ipykernel从4.10.0更改为4.9.0.该问题可以解决.

I also encountered this situation,that caused by ipykernel versions. I change ipykernel from 4.10.0 to 4.9.0.The problem can be solved.

这篇关于AttributeError:“模块"对象没有属性"to_rgba"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆