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