我想做一个饼图,但是python似乎切断了左侧和右侧的标签。有没有办法强制显示所有标签? 这是我制作情节的方法
import matplotlib.pyplot as plt
plt.clf()
# get all the groups from the database
tests ...
plt.axes([0.1, 0.1, 0.6, 0.6])
# The slices will be ordered and plotted counter-clockwise.
fracs = [test for test in tests]
labels = ...
explode = [ 0 everywhere ]
plt.pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.title('title', y=1.15)
plt.savefig(store path "_pie.png")
情节如下
有谁知道如何避免标签被切断? 谢谢 卡尔
最佳答案
您可以尝试在 savefig 命令中使用 bbox_inches='tight' 或 plt.gca().tight_layout() 作为单独的命令。
关于python - 如何强制 python 在饼图中显示整个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35840108/