饼图不允许负值
pie doesn't allow negative values
我正在尝试使用 Matplotlib 绘制饼图,尽管没有出现负值,但我一直收到错误 "pie doesn't allow negative values"!
contrib = sales_data.groupby('Region')['Sales2016'].sum().round().reset_index()
contrib["Percentage"] = (contrib.Sales2016/sum(contrib.Sales2016))*100
contrib = contrib.drop(columns = ["Sales2016"])
contrib.plot(kind = "pie", subplots = True).plot(kind = "pie",subplots=True,legend=False,figsize=(12,5),autopct="%.2f%%")
plt.show()
是否可以指出我哪里出错了?以下是 contrib 的输出:
Region Percentage
0 Central 32.994771
1 East 42.701319
2 West 24.303911
在饼图中定义参数 y
:
contrib.plot(kind = "pie",y="Percentage",labels=['Region'],legend=False,figsize=(12,5),autopct="%.2f%%")
我正在尝试使用 Matplotlib 绘制饼图,尽管没有出现负值,但我一直收到错误 "pie doesn't allow negative values"!
contrib = sales_data.groupby('Region')['Sales2016'].sum().round().reset_index()
contrib["Percentage"] = (contrib.Sales2016/sum(contrib.Sales2016))*100
contrib = contrib.drop(columns = ["Sales2016"])
contrib.plot(kind = "pie", subplots = True).plot(kind = "pie",subplots=True,legend=False,figsize=(12,5),autopct="%.2f%%")
plt.show()
是否可以指出我哪里出错了?以下是 contrib 的输出:
Region Percentage
0 Central 32.994771
1 East 42.701319
2 West 24.303911
在饼图中定义参数 y
:
contrib.plot(kind = "pie",y="Percentage",labels=['Region'],legend=False,figsize=(12,5),autopct="%.2f%%")