我试图在 matplotlib 中创建一个饼图,并希望将标签放在楔子内。我使用以下代码来做到这一点:
import matplotlib.pyplot as plt
fig = plt.figure(1, figsize=(8,8), dpi=60)
ax=fig.add_axes([0.1,0.1,0.8,0.8])
labels = ['label0','label1','label2','label3','label4','label5','label6','label7','label8',\
'label0','label1','label2','label3','label4','label5','label6','label7','label8']
colors = list('w' for _ in range(18))
fracs=list(20 for _ in range(18))
ax.pie(fracs, labels=labels, colors = colors, startangle=10,labeldistance=0.8)
plt.show()
标签似乎没有在楔形内正确对齐,如下图所示。有什么方法可以修改(或旋转)标签,以便它们可以正确显示在楔子内?
谢谢你!