function [figure1] = Plot_GMSL_PastRec(t,GMSLHR,GMSLHRSE,GMSL_Palmer,GMSL_PastRec,GMSLHRsmEnsKS)

X = [t ones(size(t))];

load('GMSL_SUMCOMP_Frederikse20.mat')

sm = 15;
GMSL_PastRecsm = GMSL_PastRec;
GMSL_PastRecsmEns = NaN(size(GMSL_PastRec,1),2000,size(GMSL_PastRec,2));
GMSL_SUMF20 = GMSL_SUMF20./1000;
GMSL_SUMF20 = GMSL_SUMF20-mean(GMSL_SUMF20(94:111,2));
for i = 1:size(GMSL_PastRec,2);
    isn = find(~isnan(GMSL_PastRec(:,i)));
    [GMSL_PastRecsm(isn,i),~,~,~,~,GMSL_PastRecsmEns(isn,:,i)] = ssatrend(GMSL_PastRec(isn,i)*1000,sm,std(detrend(GMSL_PastRec(isn,i)))*1000);
end
[GMSL_SUMF20sm,~,~,~,~,GMSL_SUMF20smEns] = ssatrend(GMSL_SUMF20(:,2)*1000,sm,mean(abs(GMSL_SUMF20(:,2)-GMSL_SUMF20(:,[1 3])),2)*1000);
[GMSLHRsm,~,~,~,~,GMSLHRsmEns] = ssatrend(GMSLHR*1000,sm,GMSLHRSE*1000);
[GMSL_Palmersm,~,~,~,~,GMSL_PalmersmEns] = ssatrend(GMSL_Palmer(:,2)*1000,sm,GMSL_Palmer(:,3)*1000/1.65);

figure1 = figure;

axes1 = axes('Parent',figure1,...
    'Position',[0.1 0.41 0.4 0.5]);
ciplot(GMSLHR-mean(GMSLHR(94:111))-GMSLHRSE,GMSLHR-mean(GMSLHR(94:111))+GMSLHRSE,t,[0 .45 .74]);
hold on
ciplot(GMSL_Palmer(:,2)-mean(GMSL_Palmer(94:end,2))-GMSL_Palmer(:,3)/1.65*2,...
    GMSL_Palmer(:,2)-mean(GMSL_Palmer(94:end,2))+GMSL_Palmer(:,3)/1.65*2,GMSL_Palmer(:,1),...
    [0 0 0])
col = [[.93 .69 .13];[.85 .33 .1];[0.47 0.67 0.19];[0.30 0.75 0.93];[.49 .18 .56];[.64 .08 .18]];
for i = 1:size(GMSL_PastRec,2)-1;
    plot(GMSL_PastRec(:,1),GMSL_PastRec(:,i+1)-nanmean(GMSL_PastRec(94:111,i+1)),'Color',col(i,:),'Linewidth',1);
end
plot(t,GMSLHR-mean(GMSLHR(94:111)),'Color',[0 .45 .74],'Linewidth',2)
plot(GMSL_Palmer(:,1),GMSL_Palmer(:,2),'Color',[0 0 0],'Linewidth',2)
plot(t(1:119),GMSL_SUMF20(:,2),'Color',[.64 .08 .18],'Linewidth',1,'Linestyle','--')

ciplot([0.09 0.09],[0.074 0.074],[1908 1920],[0 .45 .74])
plot([1908 1920],[.082 .082],'Color',[0 .45 .74],'Linewidth',2)
text(1921,.082,'This study','FontSize',8)
ciplot([0.072 0.072],[0.056 0.056],[1908 1920],[0 0 0])
plot([1908 1920],[.064 .064],'Color',[0 0 0],'Linewidth',2)
text(1921,.064,'Palmer Ensemble 2021','FontSize',8)
name = {'Church & White 2011','Hay 2015','Dangendorf 2017','Dangendorf 2019','Frederikse 2020'}
for i = 1:size(GMSL_PastRec,2)-1;
    plot([1908 1920],[.064-i*.018 .064-i*.018],'Color',col(i,:),'Linewidth',1)
    text(1921,.064-i*.018,name{i},'FontSize',8)
end
i = size(GMSL_PastRec,2);
plot([1908 1920],[.064-i*.018 .064-i*.018],'Color',col(i-1,:),'Linewidth',1,'Linestyle','--')
text(1921,.064-i*.018,'Frederikse 2020 Budget','FontSize',8)
ylabel('GMSL [m]','Fontsize',10)

set(gca,'XTick',[1900:20:2020],'XTicklabel',[],'Xlim',[1898 2022],...
    'YTick',[-.15:.05:0.05],'YTicklabel',[-.15:.05:0.05],'Ylim',[-.2 .1],...
    'Fontsize',8,'Layer','top');

axes2 = axes('Parent',figure1,...
    'Position',[0.1 0.1 0.4 0.3]);
ciplot(diff(GMSLHRsm)-2*std(diff(GMSLHRsmEns),0,2),diff(GMSLHRsm)+2*std(diff(GMSLHRsmEns),0,2),t(2:end),[0 .45 .74]);
hold on
ciplot(diff(GMSL_Palmersm)-std(diff(GMSL_PalmersmEns),0,2)*2,diff(GMSL_Palmersm)+std(diff(GMSL_PalmersmEns),0,2)*2,t(2:111),[0 0 0]);
for i = 1:size(GMSL_PastRec,2)-1;
    plot(t(2:119),diff(GMSL_PastRecsm(:,i+1)),'Color',col(i,:),'Linewidth',1);
end
plot(t(2:end),diff(GMSLHRsm),'Color',[0 .45 .74],'Linewidth',2)
plot(t(2:111),diff(GMSL_Palmersm),'Color',[0 0 0],'Linewidth',2)
plot(t(2:119),diff(GMSL_SUMF20sm),'Color',[.64 .08 .18],'Linewidth',1,'Linestyle','--')
ylabel('Rates [mmyr^{-1}]','FontSize',10)
xlabel('Year','Fontsize',10)
set(gca,'XTick',[1900:20:2020],'XTicklabel',[1900:20:2020],'Xlim',[1898 2022],...
    'YTick',[1:4],'YTicklabel',[1:4],'Ylim',[0 5],...
    'Fontsize',8,'Layer','top');

end