python的scatter中color为什么不能设置每个点的颜色
巴扎黑
巴扎黑 2017-05-18 11:02:35
[Python讨论组]
plt.scatter(x=rw.x_value,y=rw.y_value,c=point_number,colormap=plt.cm.Blues,gecolors='none',s=15)

其中point_number是指的一系列的点,然后用range()生成的一个数字列表,并且使用颜色映射,但是在运行的时候,报错ValueError: Invalid RGBA argument: 0
用的是python3
我想问一下scatter里面的color参数到底如何能够设置每个点

巴扎黑
巴扎黑

全部回复(1)
大家讲道理

下面是文档中对scatter的参数c的说明:
c : color, sequence, or sequence of color, optional, default: ‘b’
c can be a single color format string, or a sequence of color specifications of length N, or a sequence of N numbers to be mapped to colors using the cmap and norm specified via kwargs (see below). Note that c should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. c can be a 2-D array in which the rows are RGB or RGBA, however, including the case of a single row to specify the same color for all points.

可见可以传入一个序列(list之类的)

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号