我是靠谱客的博主 自由小刺猬,最近开发中收集的这篇文章主要介绍ValueError: Invalid RGBA argument: 's'.'c' argument must either be valid as mpl color(s) or as numbe,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

最近在使用matplotlib中的scatter模块时使用颜色赋值报错,报错代码如下

Traceback (most recent call last):
  File "D:Python3.7.2libsite-packagesmatplotlibcolors.py", line 174, in to_rgba
    rgba = _colors_full_map.cache[c, alpha]
KeyError: ('s', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:Python3.7.2libsite-packagesmatplotlibaxes_axes.py", line 4232, in scatter
    colors = mcolors.to_rgba_array(c)
  File "D:Python3.7.2libsite-packagesmatplotlibcolors.py", line 275, in to_rgba_array
    result[i] = to_rgba(cc, alpha)
  File "D:Python3.7.2libsite-packagesmatplotlibcolors.py", line 176, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
  File "D:Python3.7.2libsite-packagesmatplotlibcolors.py", line 220, in _to_rgba_no_colorcycle
    raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: 's'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/12819/Desktop/CTA1/vessel/data/read_data.py", line 83, in <module>
    color_list, vessel_num, vessel_slice_data)
  File "C:Users12819DesktopCTA1vesseldatavessel2color.py", line 38, in pltsave_all_vessel
    np.where(vessel_slice_data == cls)[1], c=color, s=1)
  File "D:Python3.7.2libsite-packagesmatplotlibpyplot.py", line 2864, in scatter
    is not None else {}), **kwargs)
  File "D:Python3.7.2libsite-packagesmatplotlib__init__.py", line 1810, in inner
    return func(ax, *args, **kwargs)
  File "D:Python3.7.2libsite-packagesmatplotlibaxes_axes.py", line 4253, in scatter
    .format(c)
ValueError: 'c' argument must either be valid as mpl color(s) or as numbers to be mapped to colors. Here c = mstyrose.

注意最后一行报错,显示调用c = mstyrose错误,我试着把mstyrose颜色换成其他的就好了,最后仔细查资料发现是mistyrose, 大意了, 蠢哭

最后

以上就是自由小刺猬为你收集整理的ValueError: Invalid RGBA argument: 's'.'c' argument must either be valid as mpl color(s) or as numbe的全部内容,希望文章能够帮你解决ValueError: Invalid RGBA argument: 's'.'c' argument must either be valid as mpl color(s) or as numbe所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(27)

评论列表共有 0 条评论

立即
投稿
返回
顶部