Debian Codegraph @

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

raw
1 function scaleout = fn_multigraphn_3g_shadedbands(imfn,...
2 xlab,ylab,tstring,XTick,YTickIndx,scaleIndx,nrowg,ncolg)
3 %Searching <<>> for ad hoc and specific changes.
4 %
5 %Stacking n sets of impulse responses in one graph. See fn_multigraph2_ver2.m.
6 % imfn: row: "nstp" time horizon (in the graphics),
7 % column: "nrow "variables such as responses (row in the graphics),
8 % 3rd D: across "ncol" different situations such as shocks (column in the graphics),
9 % 4th D: low band, estimate, high band (in each graph).
10 % xlab: x-axis labels on the top
11 % ylab: y-axis labels on the left
12 % tstring: string for time (e.g., month or quarter) -- x-axis labels at the bottom
13 % YTickIndx: 1: enable YTick; 0: disable;
14 % To get a better picture, it is sometimes better to set YtickIndx to zero.
15 % scaleIndx: 1: enable scale along Y-axis; 0: disable
16 % nrowg: number of rows in the graph
17 % ncolg: number of columns in the graph
18 %
19 % See imrgraph, imcerrgraph, imrerrgraph
20 %
21 % Copyright (C) 1997-2012 Tao Zha
22 %
23 % This free software: you can redistribute it and/or modify
24 % it under the terms of the GNU General Public License as published by
25 % the Free Software Foundation, either version 3 of the License, or
26 % (at your option) any later version.
27 %
28 % It is distributed in the hope that it will be useful,
29 % but WITHOUT ANY WARRANTY; without even the implied warranty of
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 % GNU General Public License for more details.
32 %
33 % If you did not received a copy of the GNU General Public License
34 % with this software, see <http://www.gnu.org/licenses/>.
35 %
36
37 nstp = size(imfn,1);
38 nrow = size(imfn,2);
39 ncol = size(imfn,3);
40 nmodels = size(imfn,4);
41 t = 1:nstp;
42 treverse = fliplr(t);
43
44 if (nargin < 9)
45 nrowg = nrow;
46 ncolg = ncol;
47 end
48 if (nrowg*ncolg < nrow*ncol)
49 nrowg
50 ncolg
51 nrow
52 ncol
53
54 error('fn_multigraphn_3g_shadedbands.m: nrowg*ncolg must be greater than nrow*ncol')
55 end
56
57
58 tempmax=zeros(ncol,1);
59 tempmin=zeros(ncol,1);
60 maxval=zeros(nrow,1);
61 minval=zeros(nrow,1);
62 for i = 1:nrow
63 for j = 1:ncol
64 tempmax(j) = -realmax;
65 tempmin(j) = realmax;
66 for k=1:nmodels
67 jnk = max(imfn(:,i,j,k));
68 tempmax(j) = max([jnk tempmax(j)]);
69 %
70 jnk = min(imfn(:,i,j,k));
71 tempmin(j) = min([jnk tempmin(j)]);
72 end
73 end
74 maxval(i)=max(tempmax);
75 minval(i)=min(tempmin);
76 end
77
78 scaleout = [maxval(:) minval(:)];
79
80 %--------------
81 % Column j: Shock 1 to N; Row i: Responses to
82 %-------------
83 %figure
84
85
86 rowlabel = 1;
87 for i = 1:nrow % column: from top to bottom
88 columnlabel = 1;
89
90 if minval(i)<0
91 if maxval(i)<=0
92 yt=[minval(i) 0];
93 else
94 yt=[minval(i) 0 maxval(i)];
95 end
96 else % (minval(i) >=0)
97 if maxval(i) > 0
98 yt=[0 maxval(i)];
99 else % (identically zero responses)
100 yt=[-1 0 1];
101 end
102 end
103
104
105 scale=[1 nstp minval(i) maxval(i)];
106
107 for j = 1:ncol % row: from left to right
108 k1=(i-1)*ncol+j;
109 subplot(nrowg,ncolg,k1)
110
111 %set(0,'DefaultAxesColorOrder',[1 0 0;0 1 0;0 0 1],...
112 % 'DefaultAxesLineStyleOrder','-|--|:')
113 %set(0,'DefaultAxesLineStyleOrder','-|--|:|-.')
114 %---<<>>
115 %set(0,'DefaultAxesColorOrder',[0 0 0],...
116 % 'DefaultAxesLineStyleOrder','-.|-.|-|--|-.|-*|--o|:d')
117
118 nseries = zeros(nstp, nmodels);
119 for k=1:nmodels
120 nseries(:,k) = imfn(:,i,j,k);
121 end
122
123 %---<<>>
124 fill([t treverse],[nseries(:,[3])' fliplr(nseries(:,[1])')],[0.8,0.8,0.8],'EdgeColor','none');
125 %plot(t,nseries(:,[1 3]), '-.k','LineWidth',1.0); %,'Color','k');
126 hold on
127 plot(t,nseries(:,[2]), '-k','LineWidth',1.5);
128 %plot(t,nseries(:,[4]), '--k','LineWidth',1.6);
129 hold off
130
131 %set(gca,'LineStyleOrder','-|--|:|-.')
132 %set(gca,'LineStyleOrder',{'-*',':','o'})
133 grid;
134 if scaleIndx
135 axis(scale);
136 end
137 %set(gca,'YLim',[minval(i) maxval(i)])
138 %
139 set(gca,'XTick',XTick)
140 if YTickIndx
141 set(gca,'YTick',yt)
142 end
143
144 if i<nrow
145 set(gca,'XTickLabelMode','manual','XTickLabel',[])
146 end
147 %set(gca,'XTickLabel',' ');
148 if (scaleIndx) && (j>1)
149 set(gca,'YTickLabel',' ');
150 end
151 if rowlabel == 1
152 %title(['x' num2str(j)])
153 %title(eval(['x' num2str(j)]))
154 if (~isempty(xlab)), title(char(xlab(j))), end
155 end
156 if columnlabel == 1
157 %ylabel(['x' num2str(i)])
158 %ylabel(eval(['x' num2str(i)]))
159 if (~isempty(ylab)), ylabel(char(ylab(i))), end
160 end
161 if (i==nrow) && (~isempty(tstring))
162 xlabel(tstring)
163 end
164 columnlabel = 0;
165 end
166 rowlabel = 0;
167 end
168
169
170 %Order of line styles and markers used in a plot.
171 %This property specifies which line styles and markers to use and in what order
172 %when creating multiple-line plots. For example,set(gca,'LineStyleOrder', '-*|:|o')sets LineStyleOrder to solid line with asterisk
173 %marker, dotted line, and hollow circle marker. The default is (-), which specifies
174 %a solid line for all data plotted. Alternatively, you can create a cell array
175 %of character strings to define the line styles:set(gca,'LineStyleOrder',{'-*',':','o'})MATLAB supports four line styles, which you can specify any number of
176 %times in any order. MATLAB cycles through the line styles only after using
177 %all colors defined by the ColorOrder property. For example,
178 %the first eight lines plotted use the different colors defined by ColorOrder with
179 %the first line style. MATLAB then cycles through the colors again, using the
180 %second line style specified, and so on.You can also specify line style and color directly with the plot and plot3 functions
181 %or by altering the properties of theline or
182 %lineseries objects after creating the graph. High-Level Functions and LineStyleOrderNote that, if the axes NextPlot property is set
183 %to replace (the default), high-level functions like plot reset
184 %the LineStyleOrder property before determining the line
185 %style to use. If you want MATLAB to use a LineStyleOrder that
186 %is different from the default, set NextPlot to replacechildren. Specifying a Default LineStyleOrderYou can also specify your own default LineStyleOrder.
187 %For example, this statementset(0,'DefaultAxesLineStyleOrder',{'-*',':','o'})
188 %creates a default value for