python的scatter中color為什么不能設(shè)置每個點的顏色
問題描述
plt.scatter(x=rw.x_value,y=rw.y_value,c=point_number,colormap=plt.cm.Blues,gecolors=’none’,s=15)
其中point_number是指的一系列的點,然后用range()生成的一個數(shù)字列表,并且使用顏色映射,但是在運行的時候,報錯ValueError: Invalid RGBA argument: 0用的是python3我想問一下scatter里面的color參數(shù)到底如何能夠設(shè)置每個點
問題解答
回答1:下面是文檔中對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.
可見可以傳入一個序列(list之類的)
相關(guān)文章:
1. docker綁定了nginx端口 外部訪問不到2. 前端 - html5 audio不能播放3. javascript - 最近用echarts做統(tǒng)計圖時遇到兩個問題!!4. javascript - 深夜被問題困擾求解惑,rn的API之PermissionsAndroidd的問題5. mysql - 我的myeclipse一直連顯示數(shù)據(jù)庫連接失敗,不知道為什么6. redis sentinel怎么跑守護進程以及日志記錄位置的?7. android權(quán)限被第三方安全軟件禁止,如何獲取該權(quán)限狀態(tài)8. android - 優(yōu)酷的安卓及蘋果app還在使用flash技術(shù)嗎?9. 利用百度地圖API定位及附件商家信息服務10. nginx - ssl加密訪問證書不受信任

網(wǎng)公網(wǎng)安備