Debian Codegraph @

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

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