%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%By Marco Bernardini & Gert Peersman (June 2017)
%Figure 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clearvars;close all;clc
dg=[51,101,0]./255;
%%
[dataBP,textBP]=xlsread('figMATLAB.xls','Fig6_BP_data');
dataBP=dataBP(1:12,:);
[dataDN,textDN]=xlsread('figMATLAB.xls','Fig6_DN_data');
dataDN=dataDN(1:12,:);
time=dataBP(:,1);
zz=zeros(size(time));
%
figure('visible','on')
subplot(2,3,1) %Interest rate
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_nr_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_nr_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_nr',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_nr',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_nr_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_nr_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.10,0.15]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Interest rate';''})
subplot(2,3,2) %Tax rate (AMTR)
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_tx_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_tx_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_tx',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_tx',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_tx_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_tx_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.1,0.3]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Tax rate';''})
subplot(2,3,3) %Price index
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_df_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_df_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_df',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_df',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_df_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_df_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.3,0.3]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Price index';''})
subplot(2,3,4) %Real debt
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_rd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_rd_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_rd',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_rd',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_rd_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_rd_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.25,1]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Private debt';''})
subplot(2,3,5) %Private debt
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_pd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_pd_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_pd',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_pd',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_pd_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_pd_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.8,0.4]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Private debt-to-GDP';''})
subplot(2,3,6) %Public debt
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_gd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_gd_90',textBP,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_gd',textBP,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_gd',textBP,'exact')),'b-^',time,dataBP(:,strmatch('upmulsdB_gd_90',textBP,'exact')),'b--',time,dataBP(:,strmatch('lomulsdB_gd_90',textBP,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-.5,0.3]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Public debt-to-GDP';''})
% subplot(2,3,7) %Nominal rate
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_nr_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_nr_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_nr',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.4,0.4]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,8) %AMTR
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_tx_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_tx_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_tx',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.4,0.4]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,9) %Price level
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_df_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_df_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_df',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.3,0.3]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,10) %Real debt
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_rd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_rd_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_rd',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.6,1.2]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,11) %Private debt
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_pd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_pd_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_pd',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-1.5,0.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,12) %Public debt
%     %Difference
%     grpyat=[time,dataBP(:,strmatch('upmulsdBA_gd_90',textBP,'exact'));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_gd_90',textBP,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataBP(:,strmatch('bmulsdBA_gd',textBP,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-1.6,0.2]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
set(findall(gcf,'type','text'),'FontSize',8) 
set(findall(gcf,'type','axes'),'FontSize',8)
set(gcf,'PaperUnits','inches','PaperPosition',[0,0,8,4]);
print('fig6_BP','-depsc')
%
figure('visible','on')
subplot(2,3,1) %Interest rate
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_nr_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_nr_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_nr',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_nr',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_nr_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_nr_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.15,0.15]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Interest rate';''})
subplot(2,3,2) %Tax rate (AMTR)
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_tx_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_tx_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_tx',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_tx',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_tx_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_tx_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.1,0.8]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Tax rate';''})
subplot(2,3,3) %Price index
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_df_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_df_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_df',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_df',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_df_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_df_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.2,0.6]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Price index';''})
subplot(2,3,4) %Real debt
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_rd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_rd_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_rd',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_rd',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_rd_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_rd_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.4,0.4]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Private debt';''})
subplot(2,3,5) %Private debt
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_pd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_pd_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_pd',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_pd',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_pd_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_pd_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-1.6,0.2]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Private debt-to-GDP';''})
subplot(2,3,6) %Public debt
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_gd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_gd_90',textDN,'exact')))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_gd',textDN,'exact')),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_gd',textDN,'exact')),'b-^',time,dataDN(:,strmatch('upmulsdB_gd_90',textDN,'exact')),'b--',time,dataDN(:,strmatch('lomulsdB_gd_90',textDN,'exact')),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.8,0.6]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Public debt-to-GDP';''})
% subplot(2,3,7) %Nominal rate
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_nr_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_nr_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_nr',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.4,0.4]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,8) %AMTR
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_tx_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_tx_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_tx',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.2,1]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,9) %Price level
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_df_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_df_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_df',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.3,0.8]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,10) %Real debt
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_rd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_rd_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_rd',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-0.4,1.2]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,11) %Private debt
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_pd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_pd_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_pd',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-2.5,0.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
% subplot(2,3,12) %Public debt
%     %Difference
%     grpyat=[time,dataDN(:,strmatch('upmulsdBA_gd_90',textDN,'exact'));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_gd_90',textDN,'exact')))];
%     patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
%     plot(time,zz,'k-'),hold on,
%     plot(time,dataDN(:,strmatch('bmulsdBA_gd',textDN,'exact')),'g','linewidth',2),hold on,
%     axis tight,box off, ylim([-2,1]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
set(findall(gcf,'type','text'),'FontSize',8) 
set(findall(gcf,'type','axes'),'FontSize',8)
set(gcf,'PaperUnits','inches','PaperPosition',[0,0,8,4]);
print('fig6_DN','-depsc')