python的scatter中color為什么不能設(shè)置每個(gè)點(diǎn)的顏色
問題描述
plt.scatter(x=rw.x_value,y=rw.y_value,c=point_number,colormap=plt.cm.Blues,gecolors=’none’,s=15)
其中point_number是指的一系列的點(diǎn),然后用range()生成的一個(gè)數(shù)字列表,并且使用顏色映射,但是在運(yùn)行的時(shí)候,報(bào)錯(cuò)ValueError: Invalid RGBA argument: 0用的是python3我想問一下scatter里面的color參數(shù)到底如何能夠設(shè)置每個(gè)點(diǎn)
問題解答
回答1:下面是文檔中對(duì)scatter的參數(shù)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.
可見可以傳入一個(gè)序列(list之類的)
相關(guān)文章:
1. 數(shù)組按鍵值封裝!2. python - flask _sqlalchemy 能否用中文作為索引條件3. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題4. python3.x - git bash如何運(yùn)行.bat文件?5. java - 阿里的開發(fā)手冊(cè)中為什么禁用map來作為查詢的接受類?6. docker不顯示端口映射呢?7. javascript - ES6規(guī)范下 repeat 函數(shù)報(bào)錯(cuò) Invalid count value8. clone - git sourceTree克隆倉庫時(shí),都不停彈出Password Required彈窗,即時(shí)輸入正確的git賬號(hào)密碼還是彈出9. javascript - webpack中alias配置中的“@”是什么意思?10. 主題切換問題,用過別人的webapp在后臺(tái)切換模板主題后手機(jī)端打開網(wǎng)頁就是切換到的主題了
