clc
clear
close all;
% 
ADVW_SaWa=1.2967e-06;%black
ADVW_SaW=-1.7321e-05;%black
ADVW_SWa=1.9278e-04;%black

% ADVW_SaWa=1.3309e-06;
% ADVW_SaW=-1.0567e-05;
% ADVW_SWa=2.6837e-04;

ADVw=ADVW_SaWa+ADVW_SaW+ADVW_SWa;
ADVe=-0.0019; %black
ADVn=0.0027;%black
% ADVe=0.0024;
% ADVn=-0.0046;

SSS_C_0_55=0.0041;
ADV_C_0_55=ADVe+ADVn+ADVw;
% FLUX_C_0_55=0.0021+6.6409e-04;  %black


PRE_C_0_55=0.0021;%包含陆地的0.0025
EVA_C_0_55=6.7361e-04;

FLUX_C_0_55=PRE_C_0_55+EVA_C_0_55;

RE_C_0_55=SSS_C_0_55-FLUX_C_0_55-ADV_C_0_55;
%--------------------------------------------------------------------------

A=[SSS_C_0_55,ADV_C_0_55,FLUX_C_0_55,RE_C_0_55];

figure('Units','centimeters','Position',[8, 2, 21, 6]);
subplot('position',[0.05 0.18 0.33 0.75]);
Budget1=[SSS_C_0_55,FLUX_C_0_55,ADV_C_0_55,RE_C_0_55];
% err=[St1_err,ep1_err,adv1_err,NaN];
b=diag(Budget1*10^3);
c=bar(b,'stack');
color=[38/255 70/255 93/255;42/255 157/255 140/255;...
    233/255 196/255 107/255;230/255 111/255 81/255];
for i=1:4
    set(c(i),'FaceColor',color(i,:),'EdgeColor','none');
end
hold on
% errorbar(Budget1*10^3,err*10^3,'k', 'Linestyle', 'None')
set(gca,'Linewidth',1,'XTickLabel',...
 {'S_t','E-P','ADV','Res'},...
   'YTick',-10:2:10,'YLim',[-3 5], ...
   'XLim',[0.5 4.5], ...
'fontname','Times New Roman','fontsize',10,'fontweight','normal');

subplot('position',[0.4 0.18 0.26 0.75]);
Budget2=[FLUX_C_0_55,PRE_C_0_55,EVA_C_0_55];
% err=[St1_err,ep1_err,adv1_err,NaN];
b=diag(Budget2*10^3);
c=bar(b,'stack');
color=[42/255 157/255 140/255;138/255 176/255 125/255;202/255 221/255 209/255];
for i=1:3
    set(c(i),'FaceColor',color(i,:),'EdgeColor','none');
end
hold on
% errorbar(Budget1*10^3,err*10^3,'k', 'Linestyle', 'None')
set(gca,'Linewidth',1,'XTickLabel',...
 {'E-P','-P','E'},...
   'YTick',-10:2:10,'YLim',[-3 5], 'ytickLabel',{' '},...
   'XLim',[0.5 3.5], ...
'fontname','Times New Roman','fontsize',10,'fontweight','normal');

subplot('position',[0.68 0.18 0.3 0.75]);
ADV1=[ADV_C_0_55,ADVe,ADVn,ADVw];
b=diag(ADV1*10^3);
% err=[adv1_err,adve1_err,advn1_err];
c=bar(b,'stack');
color=[233/255 196/255 107/255;243/255 162/255 97/255;...
    188/255 62/255 3/255;174/255 32/255 18/255;];
for i=1:4
    set(c(i),'FaceColor',color(i,:),'EdgeColor','none');
end
hold on
% errorbar(ADV1*10^3,err*10^3,'k', 'Linestyle', 'None');
set(gca,'Linewidth',1,'XTickLabel',...
 {'ADV','ADVx','ADVy','vert'},...
 'YTick',-10:2:10,'YLim',[-3 5],'ytickLabel',{' '},...
   'XLim',[0.5 4.5], ...
'fontname','Times New Roman','fontsize',10,'fontweight','normal');
% text(0.4,3,'c','horiz','center',...
% 'color','k','fontsize',15,'fontname','Times New Roman')
% % text(0.4,3,'a','horiz','center',...
% 'color','k','fontsize',15,'fontname','Times New Roman')

%  print(gcf,'-dpng','-r600','budget_0_55m');
%  print(gcf,'-depsc2','-r600','budget_0_55m')

%%
figure('Units','centimeters','Position',[8, 2, 21, 21]);
% subplot('position',[0.05 0.52 0.23 0.35]);
Budget1=[SSS_C_0_55,FLUX_C_0_55,ADV_C_0_55,RE_C_0_55];
% err=[St1_err,ep1_err,adv1_err,NaN];
b=diag(Budget1*10^3);
c=bar([1 3 6 9.5],b,'stack');
color=[0 0 0;30/255 144/255 1;...
    1 64/255 64/255;1 250/255 205/255];
for i=1:4
    set(c(i),'FaceColor',color(i,:));
end
hold on
Budget2=[PRE_C_0_55,EVA_C_0_55];
% err=[St1_err,ep1_err,adv1_err,NaN];
b=diag(Budget2*10^3);
c=bar([4.1 4.5],b,'stack');
color=[187/255 1 1;84/255 1 159/255];
for i=1:2
    set(c(i),'FaceColor',color(i,:));
end
ADV1=[ADVe,ADVn,ADVw];
b=diag(ADV1*10^3);
% err=[adv1_err,adve1_err,advn1_err];
c=bar([7.1 7.5 8],b,'stack');
color=[1 99/255 71/255;240/255 128/255 128/255;1 140/255 0];
for i=1:3
    set(c(i),'FaceColor',color(i,:));
end
% errorbar(Budget1*10^3,err*10^3,'k', 'Linestyle', 'None')
set(gca,'Linewidth',1,'XTickLabel',...
 {'S_t','E-P','ADV','Res'},...
   'YTick',-10:2:10,'YLim',[-3 5], ...
   'XLim',[0.5 7.5], ...
'fontname','Times New Roman','fontsize',10,'fontweight','normal');
%  print(gcf,'-dpng','-r600','budget_0_55m(2)');