Python 如何在matplotlib饼图中按代码选择颜色?
我有一个数据框,显示使用的颜色数量。该表具有列数量和颜色代码Python 如何在matplotlib饼图中按代码选择颜色?,python,pandas,matplotlib,charts,Python,Pandas,Matplotlib,Charts,我有一个数据框,显示使用的颜色数量。该表具有列数量和颜色代码 hsva count Color_code 0 635 100100 10 541 50100 20 406 30100 30 186 20100 40 142 30200 50 100 50400 60
hsva count Color_code
0 635 100100
10 541 50100
20 406 30100
30 186 20100
40 142 30200
50 100 50400
60 112 10100
70 33 40500
我需要建立一个饼图,每个部分都反映了这种颜色的数量。我希望使用“Color_code”列中指定的代码对其进行着色。我尝试了Mathplotlib和pandas,但我无法用这些颜色构建图形。以下是我尝试的代码:
import matplotlib.pyplot as plt
plt.pie(labels=df.index, x=df['count'], colors=df['Color_code'])
我得到以下错误:
ValueError: Invalid RGBA argument: 100100
colors
参数不支持这样的原始数字。我建议你看一看并确定正确的颜色值