clear;clc;


cyc_color = [142/255 180/255 225/255];
anti_color = [238/255 114/255 118/255];


FontSize = 11;
FontName = 'Times New Roman';
LW = 1.42;
hh1 = figure;
set(hh1,'position',[0 0 900 700])
left_color = [0 0 0];
right_color = [255 0 255]/255;
set(hh1,'defaultAxesColorOrder',[left_color;right_color]);
pos1 = [0.15 0.2 0.7 0.4];
% 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h1 = axes('Position',[0.15 0.5 0.7 0.4]);
yyaxis left
clear gca
c = bar(1.5,(windbar_Qprime_anti_dif+windbar_Qprime_cyc_dif)/2,1,'EdgeColor','k','Linewidth',1.5);
hold on;
errorbar(1.5,(windbar_Qprime_anti_dif+windbar_Qprime_cyc_dif)/2,(windbar_Qprime_anti_std+windbar_Qprime_cyc_std)/2 ,'k','Linewidth',1,'Marker','none')
grid on
ch = get(c,'children');
color=[cyc_color];
for i=1
    set(c(i),'FaceColor',color(i,:));
end





c = bar(3.5,(windprime_Qbar_anti_dif+windprime_Qbar_cyc_dif)/2,1,'EdgeColor','k','Linewidth',1.5);

errorbar(3.5,(windprime_Qbar_anti_dif+windprime_Qbar_cyc_dif)/2,(windprime_Qbar_anti_std+windprime_Qbar_anti_std)/2,'k','Linewidth',1,'Marker','none')
grid on
ch = get(c,'children');
color=[cyc_color];
for i=1
    set(c(i),'FaceColor',color(i,:));
end



xlim([0 9])
ylim([-2*10^-4 18*10^-4])

set(gca,'xlim',[0 8],'xtick',[],...
    'ylim',[-2*10^-4 18*10^-4],'ytick',-2*10^-4:2*10^-4:18*10^-4,'color','none','FontSize',FontSize,'FontName',FontName);
ylabel('(kg·kg^-^1·℃^-^1·m·s^-^1)');

% set(gca,'XTick',[1.5:2:18.5])
% set(gca,'XTickLabel',[{'$\overline U$(d$q_s\prime$/d$SST\prime$ - d$q_a\prime$/d$SST\prime$)'} {'($\overline q_s$ - $\overline q_a$)d$U\prime$/d$SST\prime$' } {'$\overline U$'} {'d$q_s\prime$/d$SST\prime$ - d$q_a\prime$/d$SST\prime$'}],'TickLabelInterpreter','latex')


% p = patch([11 11.8 11.8 11],[15*10^-4 15*10^-4 7.4*10^-4 7.4*10^-4],[238/255 114/255 118/255],'EdgeColor','k','LineWidth',0.3,'FaceAlpha',1); 
% text(12,15.7*10^-4,'Anticyclonic Eddies','color','k','FontSize',FontSize)
% 
% 
% p = patch([11 11.8 11.8 11],[13*10^-4 13*10^-4 14.4*10^-4 14.4*10^-4],[142/255 180/255 225/255],'EdgeColor','k','LineWidth',0.3,'FaceAlpha',1); 
% text(12,13.7*10^-4,'Cyclonic Eddies','color','k','FontSize',FontSize)
% 
% 


%%

% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yyaxis right
c = bar(5.5,(Ubar_percentage_anti+Ubar_percentage_cyc)/2,1,'EdgeColor','m','Linewidth',1.5);

grid on
ch = get(c,'children');
color=[cyc_color];
for i=1
    set(c(i),'FaceColor',color(i,:));
end


c = bar(7.5,(-dQprime_percentage_anti-dQprime_percentage_cyc)/2,1,'EdgeColor','m','Linewidth',1.5);
hold on;
grid on
ch = get(c,'children');
color=[cyc_color];
for i=1
    set(c(i),'FaceColor',color(i,:));
end



xlim([0 9])
ylim([-0.04 0.36])

set(gca,'xlim',[0 8],'xtick',[1.5:2:7.5],'XTickLabel',[{'$\overline U$(d$q_s\prime$/d$SST\prime$ - d$q_a\prime$/d$SST\prime$)'} {'($\overline q_s$ - $\overline q_a$)d$U\prime$/d$SST\prime$' } {'$\overline U$'} {'d$q_s\prime$/d$SST\prime$ - d$q_a\prime$/d$SST\prime$'}],...
    'ylim',[-0.04 0.36],'ytick',-0.04:0.04:0.36,'YTickLabel',[{'-4\%'} {'0\%'} {'4\%'} {'8\%'} {'12\%'} {'16\%'} {'20\%'} {'24\%'} {'28\%'} {'32\%'} {'36\%'} ],...
    'color','none','FontSize',FontSize,'FontName',FontName,'TickLabelInterpreter','latex');
% hleg1 = legend('Anticyclonic Eddies')


ylabel('(Percentage %)');

set(gca,'Fontsize',12)

xlim([0 9])
title('Difference(RCP minus HIS) in SA ','Fontsize',18)
text(-0.595,0.39,'d','FontSize',20,'FontWeight','bold')
set(gca,'XTickLabelRotation',40)
