Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/fn_seriesgraph.m

raw
1 function fn_seriesgraph(ydate,keyindx,rnum,cnum,q_m,xlab,ylab,tlab)
2 %
3 % Graph actual series or point forecasts or both (annual or monthly or quarterly)
4 %
5 % ydate: series data with dates in the first 2 columns in the order of year and month (or quarter).
6 % Some elements are allowed to be NaN if no data are available.
7 % keyindx: index for the variables to be graphed
8 % rnum: number of rows in subplot
9 % cnum: number of columns in subplot
10 % q_m: if 4 or 12, quarterly or monthly data
11 % xlab: x-axis label for what conditions imposed; e.g., conlab = 'All bar MS shocks inspl'
12 % ylab: string array for the length(keyindx)-by-1 variables
13 % tlab: title label for (e.g., as of time of forecast)
14 %-------------
15 % No output argument for this graph file
16 % See fn_foregraph.m, fn_forerrgraph.m.
17 %
18 % Tao Zha, September 2000
19 %
20 % Copyright (C) 1997-2012 Tao Zha
21 %
22 % This free software: you can redistribute it and/or modify
23 % it under the terms of the GNU General Public License as published by
24 % the Free Software Foundation, either version 3 of the License, or
25 % (at your option) any later version.
26 %
27 % It is distributed in the hope that it will be useful,
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 % GNU General Public License for more details.
31 %
32 % If you did not received a copy of the GNU General Public License
33 % with this software, see <http://www.gnu.org/licenses/>.
34 %
35
36 vyrs = ydate(:,1); % vectorized
37 hornum = cell(length(vyrs),1); % horizontal year (number)
38 count=0;
39 for k=vyrs'
40 count=count+1;
41 jnk=num2str(k);
42 hornum{count}=jnk(3:4); % e.g., with '1990', we have '90'
43 end
44
45 count=0;
46 for i = keyindx
47 count = count+1;
48 subplot(rnum,cnum,count)
49 plot(ydate(:,1)+ydate(:,2)/q_m,ydate(:,2+i))
50
51 if (ydate(1,2)==0) % only for annual growth rates (not for, say, monthly annualized rates)
52 set(gca,'XLim',[vyrs(1) vyrs(end)])
53 set(gca,'XTick',vyrs)
54 set(gca,'XTickLabel',char(hornum))
55 end
56
57 if i==keyindx(1)
58 title(tlab)
59 elseif i>=length(keyindx) %i>=length(keyindx)-1
60 xlabel(xlab)
61 end
62 %
63 grid
64 ylabel(char(ylab(i)))
65 end