绘制一个整洁的饼图

问题描述 投票:-1回答:2

我画了一张饼图,但它太乱了!我附上了我的脚本生成的示例图像!

希望有人可以帮我绘制一张整齐的图表! enter image description here

我的剧本:

graph

emotions = [neutral_avg,sadness_avg,disgust_avg,anger_avg,surprise_avg,fear_avg,happiness_avg]
labels = ['Neutral','Sadness','Disgust','Anger','Surprise','Fear','Happiness']
plt.pie(emotions,labels = labels,shadow=True, startangle=140,autopct='%1.1f%%')
date_string = time.strftime("%Y-%m-%d")
plt.savefig(date_string+'.png')
python matplotlib graph pie-chart
2个回答
0
投票
plt.pie(emotions, labels=labels, labeldistance = 1.3,pctdistance = 1.1,shadow=True, startangle=140, autopct='%1.1f%%')
plt.axis('equal')

修改labeldistancepctdistance到你想要的。


0
投票

你能试试:ax1.axis('equal')例子:

`fig1, ax1 = plt.subplots()
 ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
    shadow=True, startangle=90)
ax1.axis('equal')`
© www.soinside.com 2019 - 2024. All rights reserved.