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. ddos - apache日志很多其它網址,什么情況?2. 怎么在phpstudy中用phpexcel上傳數據到MYSQL?3. javascript - 百度搜索網站,如何讓搜索結果顯示一張圖片加上一段描述,如圖;求教4. 二維數組怎么重新組合5. docker綁定了nginx端口 外部訪問不到6. vue.js - centos 使用vue-cli. 執行npm run dev 報錯7. php由5.3升級到5.6后,登錄網站,返回的是php代碼,不是登錄界面,各位大神有知道的嗎?8. javascript - 如何在同一臺電腦上配置不同主機的2個git賬號?9. 發現了多個名稱為[spring_web]的片段。相對順序不合法10. android - 使用vue.js進行原生開發如何進行Class綁定
