function [figure1, TACC_GMSLPastRec] = Plot_Acceleration_1970(t,GMSL_Palmer,GMSLHR,GMSSLHR,GBSLHR,GMSLHRSE,GMSSLHRSE,GBSLHRSE,GMSLALT)

% Acceleration since 1970
yfit = NaN(122,9);
s70 = find(t>=1970&t<2010);
X = [t(s70).^2 t(s70) ones(size(t(s70)))];
m = X\[GMSL_Palmer(s70,2),GMSLHR(s70)];
TACC_GMSLPastRec(:,1) = m(1,:)*2000;
yfit(s70,1:2) = X*m;
T = trend_new(2,t(s70),GMSL_Palmer(s70,2),'N');
TACC_GMSLPastRec(1,2) = 2000*T(3);
T = trend_new(2,t(s70),GMSLHR(s70),'N');
TACC_GMSLPastRec(2,2) = 2000*T(3);

s70 = find(t>=1970);
X = [t(s70).^2 t(s70) ones(size(t(s70)))];
m = X\[GMSLHR(s70),GBSLHR(s70),GMSSLHR(s70)];
TACC_GMSLPastRec(3:5,1) = m(1,:)*2000;
yfit(s70,3:5) = X*m;
T = trend_new(2,t(s70),GMSLHR(s70),'N');
TACC_GMSLPastRec(3,2) = 2000*T(3);
T = trend_new(2,t(s70),GBSLHR(s70),'N');
TACC_GMSLPastRec(4,2) = 2000*T(3);
T = trend_new(2,t(s70),GMSSLHR(s70),'N');
TACC_GMSLPastRec(5,2) = 2000*T(3);


s = find(t>=1993);
X = [t(s).^2 t(s) ones(size(t(s)))];
m = X\[GMSLALT,GMSLHR(s),GBSLHR(s),GMSSLHR(s)];
TACC_GMSLPastRec(6:9,1) = m(1,:)*2000;
yfit(s,6:9) = X*m;
T = trend_new(2,t(s),GMSLALT,'N');
TACC_GMSLPastRec(6,2) = 2000*T(3);
T = trend_new(2,t(s),GMSLHR(s),'N');
TACC_GMSLPastRec(7,2) = 2000*T(3);

figure1 = figure;

axes1 = axes('Parent',figure1,...
    'Position',[0.1 0.41 0.4 0.5]);
ciplot(GMSL_Palmer(s70(1:end-11),2)-mean(GMSL_Palmer(94:end,2))-GMSL_Palmer(s70(1:end-11),3)/1.65*2+.15,...
    GMSL_Palmer(s70(1:end-11),2)-mean(GMSL_Palmer(94:end,2))+GMSL_Palmer(s70(1:end-11),3)/1.65*2+.15,GMSL_Palmer(s70(1:end-11),1),...
    [0 0 0])
hold on
ciplot(GMSLHR(s70)-mean(GMSLHR(94:111))-GMSLHRSE(s70)+.15,GMSLHR(s70)-mean(GMSLHR(94:111))+GMSLHRSE(s70)+.15,t(s70),[0 .45 .74]);
ciplot(GBSLHR(s70)-mean(GBSLHR(94:111))-GBSLHRSE(s70)+.075,GBSLHR(s70)-mean(GBSLHR(94:111))+GBSLHRSE(s70)+.075,t(s70),[.85 .33 .1]);
ciplot(GMSSLHR(s70)-mean(GMSSLHR(94:111))-GMSSLHRSE(s70)+.025,GMSSLHR(s70)-mean(GMSSLHR(94:111))+GMSSLHRSE(s70)+.025,t(s70),[.93 .69 .13]);
plot(GMSL_Palmer(s70(1:end-11),1),GMSL_Palmer(s70(1:end-11),2)+.15,'Color',[0 0 0],'Linewidth',1)
plot(t(s70),GMSLHR(s70)-mean(GMSLHR(94:111))+.15,'Color',[0 .45 .74],'Linewidth',1)
plot(t(s),GMSLALT-mean(GMSLHR(94:111))+.15,'Color',[0 0 0],'Linewidth',1,'Linestyle',':')
plot(t(s70),GBSLHR(s70)-mean(GBSLHR(94:111))+.075,'Color',[.85 .33 .1],'Linewidth',1)
plot(t(s70),GMSSLHR(s70)-mean(GMSSLHR(94:111))+.025,'Color',[.93 .69 .13],'Linewidth',1)
plot(GMSL_Palmer(s70(1:end-11),1),yfit(s70(1:end-11),1)+.15,'Color',[0 0 0],'Linewidth',2)
plot(t(s70),yfit(s70,3)-mean(GMSLHR(94:111))+.15,'Color',[0 .45 .74],'Linewidth',2)
plot(t(s70),yfit(s70,4)-mean(GBSLHR(94:111))+.075,'Color',[.85 .33 .1],'Linewidth',2)
plot(t(s70),yfit(s70,5)-mean(GMSSLHR(94:111))+.025,'Color',[.93 .69 .13],'Linewidth',2)

plot([1970 1976],[.22 .22],'Color',[0 0 0],'Linewidth',1,'Linestyle',':')
text(1978,.22,'GMSL Satellite Altimetry','FontSize',8)
ciplot([0.205 0.205],[0.195 0.195],[1970 1976],[0 .45 .74])
plot([1970 1976],[.2 .2],'Color',[0 .45 .74],'Linewidth',2)
text(1978,.2,'GMSL this study','FontSize',8)
ciplot([0.185 0.185],[0.175 0.175],[1970 1976],[0 0 0])
plot([1970 1976],[.18 .18],'Color',[0 0 0],'Linewidth',2)
text(1978,.18,'GMSL Palmer Ensemble 2022','FontSize',8)
ciplot([0.165 0.165],[0.155 0.155],[1970 1976],[.85 .33 .1])
plot([1970 1976],[.16 .16],'Color',[.85 .33 .1],'Linewidth',2)
text(1978,.16,'Barystatic','FontSize',8)
ciplot([0.145 0.145],[0.135 0.135],[1970 1976],[.93 .69 .13])
plot([1970 1976],[.14 .14],'Color',[.93 .69 .13],'Linewidth',2)
text(1978,.14,'Steric','FontSize',8)
ylabel('GMSL [m] + artificial offset','Fontsize',10)
xlabel('Year','Fontsize',10)

set(gca,'XTick',[1970:10:2020],'XTicklabel',[1970:10:2020],'Xlim',[1969 2022],...
    'YTick',[0:.05:0.2],'YTicklabel',[0:.05:0.2],'Ylim',[-.025 .225],...
    'Fontsize',8,'Layer','top');

axes2 = axes('Parent',figure1,...
    'Position',[0.1 0.15 0.4 0.2]);
bar(1,TACC_GMSLPastRec(1,1),'Facecolor',[0 0 0])
hold on
bar(2,TACC_GMSLPastRec(2,1),'Facecolor',[0 .45 .74])
bar(4,TACC_GMSLPastRec(3,1),'Facecolor',[0 .45 .74])
b = bar(5,[TACC_GMSLPastRec(4,1),TACC_GMSLPastRec(5,1)],'stacked')
b(1).FaceColor = [.85 .33 .1];b(2).FaceColor = [.93 .69 .13];
bar(7,TACC_GMSLPastRec(6,1),'Facecolor',[0 0 0])
bar(8,TACC_GMSLPastRec(7,1),'Facecolor',[0 .45 .74])
b = bar(9,[TACC_GMSLPastRec(8,1),TACC_GMSLPastRec(9,1)],'stacked')
b(1).FaceColor = [.85 .33 .1];b(2).FaceColor = [.93 .69 .13];
errorbar([1 2 4:5 7:9],TACC_GMSLPastRec([1 2 3 3 6 7 7],1),TACC_GMSLPastRec([1 2 3 3 6 7 7],2),'k','LineStyle','none')

set(gca,'XTick',[1 2 4.5 7 8.5],'XTicklabel',{'Palmer','This study','This study','Altimetry','This study'},'Xlim',[0 10],...
    'YTick',[.05:.05:0.2],'YTicklabel',[.05:.05:0.2],'Ylim',[0 .25],...
    'Fontsize',8,'Layer','top');
xtickangle(45)
ylabel('Acceleration [mmyr^{-2}]','Fontsize',10)


end