首页 > 解决方案 > 如何解决带有标签间距的饼图问题?

问题描述

有人可以帮我做这个饼图吗?我希望文本和 % 就位,而不是像这张图片那样相互挤压。

这是我的代码

import matplotlib.pyplot as plt

labels= ['Corallina elongata', 'Encrusting Corallines', 'Cystoseira compressa', 'Green algae like ulvales and cladophorales', 'Posidonia reefs', 'Haliptilon sp', 'Cyanophycea and other blue green algae', 'Cystoseira amentacea var. stricta 5, Continuous belt', 'Cystoseira amentacea var. stricta 3, Abundant patches', 'Cystoseira crinita', 'Cystoseira amentacea var. stricta 2, Scarce patches', 'The Mediterranean mussel Mytilus galloprovincialis']
sizes= [3723.34, 1568.32, 1605.31, 557.12, 1388.83, 271.24, 128.53, 342.05, 345.31, 362.70, 25.23,  18.66]
plt.pie(sizes, labels=labels, startangle=90, shadow=True, autopct='%1.1f%%')
plt.axis('equal')
plt.show()

结果:

结果

标签: pythonmatplotlibpie-chart

解决方案


推荐阅读