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. javascript - vue 移動端的input 數字輸入優化2. java - mongodb分片集群下,count和聚合統計問題3. java - 自己制作一個視頻播放器,遇到問題,用的是內置surfaceview類,具體看代碼!4. android - java 泛型不支持數組,那么RxJava的Map集合有什么方便的手段可以定義獲得一串共同父類集合數據呢?5. 服務器端 - 采用nginx做web服務器,C++開發應用程序 出現拒絕連接請求?6. 為什么我ping不通我的docker容器呢???7. 關于docker下的nginx壓力測試8. python - pandas按照列A和列B分組,將列C求平均數,怎樣才能生成一個列A,B,C的dataframe9. javascript - 有什么兼容性比較好的辦法來判斷瀏覽器窗口的類型?10. java - 靜態屬性中的賦值和靜態代碼塊中的賦值有什么區別?
