【发布时间】:2015-01-07 17:46:10
【问题描述】:
我在一个图中有 2 个图表,我希望图例出现在它们下方的空白处。出于某种原因,它总是在其中一个馅饼的顶部,即使我做“底部”。
另外,我使用了两次“title”属性来分别标记每个图表。我怎样才能移动图表下方的标签? title 属性似乎没有“loc”属性。
谢谢!
labels = 'a', 'b', 'c', 'd'
fracsQuads = [6, 14, 1, 79]
fracsTrips = [11, 16, 7, 66]
colors=['Goldenrod', 'LimeGreen', 'Crimson', 'DeepSkyBlue']
explode=(0, 0, 0, 0)
# Make square figures and axes
the_grid = GridSpec(1, 2)
plt.subplot(the_grid[0, 0], aspect=1)
plt.pie(fracsQuads, autopct='%1.0f%%', colors=colors, pctdistance=1.2)
plt.title('Four knockouts')
plt.subplot(the_grid[0, 1], aspect=1)
plt.pie(fracsTrips, explode=explode, autopct='%.0f%%', colors=colors, pctdistance=1.2)
plt.title('Three knockouts')
#plt.legend(labels, loc='best')
font = {'family' : 'normal',
'weight' : 'normal',
'size' : 14}
matplotlib.rc('font', **font)
plt.show()
plt.savefig('pythonFigureTest.png', facecolor='white', transparent=True)
【问题讨论】:
标签: python matplotlib