python的scatter中color为什么不能设置每个点的颜色
问题描述
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之类的)
相关文章:
1. mac连接阿里云docker集群,已经卡了2天了,求问?2. 通过Java独立应用程序运行JMeter测试用例,而无需在本地安装JMeter3. css3 - 关于CSS核心技术关键字都有哪些?4. css - 关于阿里ICON-FONT的cdn线上引用,cdn地址变化,应该如何处理?5. html5 - CORS机制的Access-Control-Allow-Origin应该怎么设置?6. 没明白盒子的height随width的变化这段css是怎样实现的?7. angular.js - 关于angular排序筛选后,懒加载的图片无法显示的问题。8. angular.js - 在angular就是的html中用innerHTML={{value}},动态的插入9. html5 - ionic运行在Android4.3及其以下的问题10. PHPstudy创建网站成功,用浏览器打开文件,浏览器地址显示“loaclhost:63342/,错
