python - 如何解决带有标签间距的饼图问题?
问题描述
有人可以帮我做这个饼图吗?我希望文本和 % 就位,而不是像这张图片那样相互挤压。
这是我的代码
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()
结果:
解决方案
推荐阅读
- css - 当输入字段(同一元素的子元素)占位符文本被隐藏时修改元素的 ::after
- mt4 - 松较高级如何避免重绘?
- visual-studio - 关于安装 QT for Visual Studio 2019 的安装错误
- ios - 快速日期格式错误与月份和年份
- python - 防止同一访问者在 Flask 中多次回答投票
- c++ - 矢量的 begin() 和 end() 是如何工作的,我应该如何为我的自定义矢量编写它?
- google-bigquery - 如何使用气流将 bigquery 导出到 bigtable?架构问题
- json - 想在 perl 中读取 JSON 文件字符串(多个值)
- sqlite - 使用 sqlite 递归计算出现次数
- python - 无法以 root 身份运行 selenium