Matplotlib 属性错误:';模块';对象没有属性';至rgba';

Matplotlib 属性错误:';模块';对象没有属性';至rgba';,matplotlib,Matplotlib,使用matplotlib.pyplot显示图像时出错 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, **

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

      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'
5 plt.ylim(-5,6)
6 plt.标题(“问题1(c):样本聚类数据(每个聚类10000分)”
---->7 plt.show()
C:\Users\yashi\Anaconda3\envs\CSC411\lib\site packages\matplotlib\pyplot.py in show(*args,**kw)
242在非交互模式下,显示所有图形和块,直到
243数字已关闭;在交互模式下,它没有
-->244影响,除非数字是在更改之前创建的
245非交互到交互模式(不推荐)。在里面
246在这种情况下,它会显示图形,但不会阻塞。
C:\Users\yashi\Anaconda3\envs\CSC411\lib\site packages\ipykernel\pylab\backend\u inline.pyc in show(关闭,块)
37显示器(
38 figure_manager.canvas.figure,
--->39元数据=\u获取\u图\u元数据(图\u manager.canvas.figure)
40             )
41最后:
元数据中的C:\Users\yashi\Anaconda3\envs\CSC411\lib\site packages\ipykernel\pylab\backend\u inline.pyc(图)
172“获取一些元数据以帮助显示图形。”“”
173#确定是否需要背景以确保易读性
-->174如果_是透明的(图get_facecolor()):
175#背景是透明的
176 ticksLight=_是光([label.get_color())
C:\Users\yashi\Anaconda3\envs\CSC411\lib\site packages\ipykernel\pylab\backend\u inline.pyc in是透明的(颜色)
193 def_是透明的(颜色):
194“从alpha确定透明度”
-->195 rgba=颜色。至_rgba(颜色)
196返回rgba[3]<.5
AttributeError:“模块”对象没有“to_rgba”属性
据报道,


我将matplotlib更新为2.23,但它仍然不起作用。如何修复它?

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

在Mac上的windows/终端上运行命令行并执行以下操作:

conda install ipykernel=4.9.0

请随时提供问题的详细信息。添加
打印(matplotlib.\uuuuuu版本)
查看2.2.3是否真的被使用。@ImportanceOfBeingErnest是的,它是2.23如果你想让别人知道是怎么回事,你应该更合作一点。你提供的信息根本不足以找出问题的任何方面。你需要一个其他人可以运行的文件,你需要说明你是如何运行的。你是如何做到的更改您上面提到的ipykernel版本?您能帮助我吗?使用pip(如
pip install ipykernel=4.9.0
)对我不起作用。在这里使用windows 10。已经做了所有建议没有运气也重新启动我的pcI必须返回到4.8.0,才能与matplotlib 1.5.3一起工作。ipykernel 4.9.0仍然给出错误on a_rgba()