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 - h5 video層級太高導致浮在div上面,如何解決?2. mysql ER_BAD_DB_ERROR: Unknown database ’test’3. linux - Ubuntu下編譯Vim8(+python)無數次編譯失敗4. python - pyspider爬pdf爬了一小段時間后就不動了5. mysql - 記得以前在哪里看過一個估算時間的網站6. 如何合并兩張具有相同結構的mysql表7. javascript - Ajax加載Json時,移動端頁面向左上角縮小一截兒,加載完成后才正常顯示,這該如何解決?8. python中怎么對列表以區間進行統計?9. css - 請問B站頂部的模糊半透明導航條是怎么實現的呢?10. python運行后沒有任何反饋要怎么排查
