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. android - 为 AppBarLayout 设置的背景图片 TransitionDrawable 为什么只在第一次打开的时候有效?2. docker网络端口映射,没有方便点的操作方法么?3. java - 请教一个IO的问题4. nginx - 关于javaweb项目瘦身问题,前期开发后,发现项目占用存贮空间太大,差不多1.2个G,怎么实现瘦身,动态页面主要是jsp。5. node.js - 安装puer前端服务器不成功6. jquery - 移动端如何写弹性效果7. angular.js - angular内容过长展开收起效果8. java - 一个泛型标签问题9. mysql - 我的myeclipse一直连显示数据库连接失败,不知道为什么10. node.js - 问个问题 Uncaught (in promise)

网公网安备