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