Debian Codegraph @

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

raw
1 function scaleout = fn_multigraph1_ver2_all_labels(imf1,xlab,ylab,tstring,XTick,YTickIndx,scaleIndx,nrowg,ncolg)
2 %scaleout = fn_multigraph1_ver2_all_labels(imf1,xlab,ylab,tstring,XTick,YTickIndx,scaleIndx,nrowg,ncolg)
3 %
4 % Version 2 for plotting only one set of impulse responses in one graph. See fn_multigraph1_ver2.
5 % imf1 -- each has 3 dimensions. Row: horizon; column: 'nrow' variables; 3rd dim: 'ncol' situations such as shocks or regimes.
6 % imf1: row: "nstp" time horizon (in the graphics), column: "nrow "variables (row in
7 % the graphics), 3rd D: across "ncol" different situations such as shocks or regimes (column in the graphics)
8 % xlab: x-axis labels on the top. Use [] if no label is needed.
9 % ylab: y-axis labels on the left. Use [] if no label is needed.
10 % tstring: string for time (e.g., month or quarter) -- x-axis labels at the bottom. Use [] if no label is needed.
11 % YTickIndx: 1: enable YTick; 0: disable. Often set to zero to get a better picture.
12 % scaleIndx: 1: enable scale along Y-axis; 0: disable
13 % nrowg: number of rows in the graph
14 % ncolg: number of columns in the graph
15 %
16 % See fn_multigraph1_ver2, imrgraph, imcerrgraph, imrerrgraph
17 %
18 % Copyright (C) 1997-2012 Tao Zha
19 %
20 % This free software: you can redistribute it and/or modify
21 % it under the terms of the GNU General Public License as published by
22 % the Free Software Foundation, either version 3 of the License, or
23 % (at your option) any later version.
24 %
25 % It is distributed in the hope that it will be useful,
26 % but WITHOUT ANY WARRANTY; without even the implied warranty of
27 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 % GNU General Public License for more details.
29 %
30 % If you did not received a copy of the GNU General Public License
31 % with this software, see <http://www.gnu.org/licenses/>.
32 %
33
34 nstp = size(imf1,1);
35 nrow = size(imf1,2);
36 ncol = size(imf1,3);
37 t = 1:nstp;
38
39 if (nargin < 8)
40 nrowg = nrow;
41 ncolg = ncol;
42 end
43 if (nrowg*ncolg < nrow*ncol)
44 error('fn_multigraph1_ver2.m: nrowg*ncolg must equal to or greater than nrow*ncol')
45 end
46
47 temp1=zeros(ncol,1);
48 temp2=zeros(ncol,1);
49 maxval=zeros(nrow,1);
50 minval=zeros(nrow,1);
51 for i = 1:nrow
52 for j = 1:ncol
53 %jnk1=max(firsth(:,i,j));
54 %jnk2=max(firstl(:,i,j));
55 %jnk3=max(firsth1(:,i,j));
56 %jnk4=max(imf2(:,i,j));
57 jnk5=max(imf1(:,i,j));
58
59 temp1(j)=max([jnk5]);
60 %
61 %jnk1=min(firstl(:,i,j));
62 %jnk2=min(firsth(:,i,j));
63 %jnk3=min(firstl1(:,i,j));
64 %jnk4=min(imf2(:,i,j));
65 jnk5=min(imf1(:,i,j));
66
67 temp2(j)=min([jnk5]);
68 end
69 maxval(i)=max(temp1);
70 minval(i)=min(temp2);
71 end
72
73 scaleout = [maxval(:) minval(:)];
74
75 %--------------
76 % Column j: situation 1 to N; Row i: variables (ie responses to)
77 %-------------
78 %figure
79 rowlabel = 1;
80 for i = 1:nrow % column: from top to bottom
81 columnlabel = 1;
82
83 if minval(i)<0
84 if maxval(i)<=0
85 yt=[minval(i) 0];
86 else
87 yt=[minval(i) 0 maxval(i)];
88 end
89 else % (minval(i) >=0)
90 if maxval(i) > 0
91 yt=[0 maxval(i)];
92 else % (identically zero responses)
93 yt=[-1 0 1];
94 end
95 end
96
97
98 scale=[1 nstp minval(i) maxval(i)];
99 for j = 1:ncol % row: from left to right
100 k1=(i-1)*ncol+j;
101 subplot(nrowg,ncolg,k1)
102 plot(t,imf1(:,i,j)) %,t,imf2(:,i,j),'--')
103 %t,[firstl(:,i,j) firsth(:,i,j)],':');
104 grid;
105 if scaleIndx
106 axis(scale);
107 end
108 %set(gca,'YLim',[minval(i) maxval(i)])
109 %
110 set(gca,'XTick',XTick)
111 if YTickIndx
112 set(gca,'YTick',yt)
113 end
114
115 % if i<nrow
116 % set(gca,'XTickLabelMode','manual','XTickLabel',[])
117 % end
118 %set(gca,'XTickLabel',' ');
119 if (scaleIndx) && (j>1)
120 set(gca,'YTickLabel',' ');
121 end
122 %if rowlabel == 1
123 % %title(['x' num2str(j)])
124 % %title(eval(['x' num2str(j)]))
125 % title(char(xlab(j)))
126 %end
127 if (~isempty(xlab))
128 title(char(xlab(i)))
129 end
130 %if columnlabel == 1
131 % %ylabel(['x' num2str(i)])
132 % %ylabel(eval(['x' num2str(i)]))
133 % ylabel(char(ylab(i)))
134 %end
135 if (~isempty(ylab))
136 ylabel(char(ylab(i)))
137 end
138 if (i==nrow) && (~isempty(tstring))
139 xlabel(tstring)
140 end
141 columnlabel = 0;
142 end
143 rowlabel = 0;
144 end