如何从情节中删除熊猫系列名称?

时间:2020-05-15 04:08:10

标签: python matplotlib

data.groupby('parental level of education')['gender'].count().plot(kind='pie', autopct='%.1f%%', title='Population Composition',fontsize=10)

以下代码绘制了一个饼图,该饼图的名称写为“性别”。我要删除它。我怎么做? Pie Chart Image

3 个答案:

答案 0 :(得分:0)

似乎自动将性别视为虚假信息。完全是回旋处,但这可行。

s = data.groupby('parental level of education')['gender'].count()
s.name = ""
s.plot(kind='pie', autopct='%.1f%%', title='Population Composition',fontsize=10)

答案 1 :(得分:0)

通过用空字符串设置y轴标签。

ax=data.groupby('parental level of education')['gender'].count().plot(kind='pie', autopct='%.1f%%', title='Population Composition',fontsize=10)
ax.set_ylabel('')

答案 2 :(得分:0)

系列名称进入 ylabelplot() 参数。这可以在调用 plot() 函数时使用(如另一个答案 here 中所建议的)。

对于您的问题,这类似于

data.groupby('parental level of education')['gender'].count().plot(
kind='pie', 
autopct='%.1f%%', 
title='Population Composition',
fontsize=10, 
ylabel='') ## Here is the change :P