【发布时间】:2016-03-25 00:49:28
【问题描述】:
我使用 Matplotlib 在 Python 中制作了一个非常简单的饼图,我想编辑标签的对齐方式。我在标签中使用了\n 来拆分行,因为标签对于一行来说太长了。但正如您从名为“饼图图像”的图片中看到的那样,目前它是一种奇怪的对齐方式。我真的很想让它居中对齐。
对于 Matplotlib 中的其他图表/图形类型,有一个名为 align 的参数,您可以将其设置为 center,但是,plt.pie(...) 似乎没有此属性。
这是我的代码:
import matplotlib.pyplot as plt
k = [7,15]
labels = 'Strongly and Mostly \n Agree', 'Strongly/Mostly Disagree \n and In the Middle'
plt.pie(k, labels= labels)
plt.show()
有什么想法吗?
【问题讨论】:
标签: python matplotlib charts labels