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. 一個走錯路的23歲傻小子的提問2. python - 如何使用pykafka consumer進行數據處理并保存?3. javascript - SuperSlide.js火狐不兼容怎么回事呢4. java - 創建maven項目失敗了 求解決方法5. android - 安卓activity無法填充屏幕6. java-se - 正在學習Java SE,為什么感覺學習Java就是在學習一些API。7. 運行python程序時出現“應用程序發生異常”的內存錯誤?8. python - django 里自定義的 login 方法,如何使用 login_required()9. java - 安卓電視盒子取得了root權限但是不能安裝第三方應用,請問該怎么辦?10. 一個mysql聯表查詢的問題
