2014-04-03 31 views
0

使用此代碼來繪製多個圖表我似乎無法調整標題上的字體大小,我需要它們更大......代碼中的字體代碼使用軸標籤粗體顯示但似乎沒有大膽的標題,也沒有改變軸標籤的大小,也沒有大膽或改變標題..所以我想它會被佈局中的東西覆蓋?使用Matplotlib調整組圖中的字體大小

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]))) 

息率是這樣的: ​​

+0

'ax.set_title( '標題文本',尺寸爲100)' –

+0

標題被動態地設定在最後一行通過.plot(ax = ax ......那麼如何? – dartdog

+0

修改最後一行爲[curr_month]),size = 100))什麼都不做 – dartdog

回答

0

最簡單的方法:

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

+0

這樣做!當我在最後的當前行之後添加它時,在繪圖創建之後。 – dartdog