我是靠谱客的博主 自由小刺猬,这篇文章主要介绍ValueError: Invalid RGBA argument: 's'.'c' argument must either be valid as mpl color(s) or as numbe,现在分享给大家,希望可以做个参考。
最近在使用matplotlib中的scatter模块时使用颜色赋值报错,报错代码如下
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33Traceback (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:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复