使用Matplotlib调整组图中的字体大小

时间:2014-04-03 14:59:41

标签: python matplotlib pandas

使用此代码绘制多个图表我似乎无法调整标题上的字体大小,我需要它们更大...代码中的字体代码粗体轴标签但似乎没有加粗标题也不改变轴标签的大小,也不改变粗体或更改标题..所以我猜它会被布局中的某些东西覆盖?

area_tabs=['1']
nrows = int(math.ceil(len(area_tabs) / 2.))
figlen=nrows*7 #adjust the figure size height to be sized to the number of rows
plt.rcParams['figure.figsize'] = 25,figlen
font = {'family' : 'normal',
    'weight' : 'bold',
    'size'   : 30}
matplotlib.rc('font', **font)
fig, axs = plt.subplots(nrows, 2, sharey=False)
for ax, area_tabs in zip(axs.flat, area_tabs):
    ax.xaxis.grid(True, which='both')
    actdf, aname = get_data(area_tabs)
    fullyrs,lastq,fcast_yr,projections,yrahead,aname,actdf,merged2,mergederrs,montdist,ols_test,    mergedfcst,curr_month=do_projections(actdf,aname)
    lastyrtot=str(merged2['Units'][-2:-1].iloc[0])
    mergederrs[['fcast','Units']].tail(12).plot(ax=ax, title='''Area: {0} Forecast for 2014 {1:,} vs. Actual 2013 of {2:,}
{3} sales year to date, compared to forecast of {4} a cumulative error of {5}%'''.format(unicode(aname),int(mergederrs['fcastcum'][-1:].iloc[0]),
int(float((lastyrtot))),int(mergederrs['unitscum'][curr_month]),int(mergederrs['fcastcum'][curr_month]),(mergederrs['cumerrpercent'][curr_month])))

产生这样的东西: Statewide Chart

1 个答案:

答案 0 :(得分:0)

最简单的方法:

ax.set_title(ax.get_title(), fontsize=20)