如果我有一個熊貓資料框:
x = pd.DataFrame(np.random.randn(5,5), columns = ['0','1.1','1.2', '2.1', '2.2'])
并想像這樣繪制它:
x.plot()

我如何按組為它們著色,例如一種顏色中的 0、一種顏色中的 1.1 和 1.2、一種顏色中的 2.1 和 2.2。我還想傳說中??的五種型別都說
uj5u.com熱心網友回復:
您可以只添加一個帶有圖數長度的顏色串列:而不是x.plot()您寫:
x.plot(color=['r', 'g', 'g', 'b', 'b']) # red green green blue blue
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/495135.html
標籤:Python 熊猫 matplotlib
