我正在创建一个饼图,以在列["PTypes"]
中显示数据集中可用属性类型的百分比。我使用了下面的代码
`import matplotlib.pyplot as plt
# Pie chart
df['PType'].value_counts().plot(kind='pie', autopct='%1.1f%%', pctdistance=1, labeldistance=1.3, fontsize=12, figsize=(8,6))
plt.pie(sizes, colors = colors, autopct='%1.1f%%', startangle=90, pctdistance=0.85, explode = explode)
#draw circle
centre_circle = plt.Circle((0,0),0.70,fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
# Equal aspect ratio ensures that pie is drawn as a circle
ax.axis('equal')
plt.tight_layout()
plt.show()`
这就是它产生的结果
是的,我知道这看起来有点奇怪。我需要调整标签,去掉顶部的红色背景,并引入一个图例
我该怎么做
目前没有回答
相关问题 更多 >
编程相关推荐