clear;close all


r1=10; theta=0:pi/100:2*pi;
x1=r1*cos(theta); y1=r1*sin(theta);
r2=20; theta=0:pi/100:2*pi;
x2=r2*cos(theta); y2=r2*sin(theta);

letter = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h','i','j','k','l'}
load('dif_double.mat')
R = 1

dif_double(10:11,:) = 0.955078
figure;set(gcf,'position',[0 0 400 500])
hold on
pcolor(nanmean(SST_meso_anti_RCP85,3)-nanmean(SST_meso_anti_Bhist,3));;shading interp;;xlim([2 50]);ylim([2 50]);caxis([-0.5 0.5]);colormap(flipud(dif_double));

plot(26,26,'.','color',[1 1 1],'Markersize',26);

[C,h] = contour(nanmean(SHF_meso_anti_RCP85,3)-nanmean(SHF_meso_anti_Bhist,3),2:2:10,'k','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

[C,h] = contour(nanmean(SHF_meso_anti_RCP85,3)-nanmean(SHF_meso_anti_Bhist,3),-10:2:-2,'k--','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

plot(x2+26,y2+26,'-','color',[ 1 1 1],'Linewidth',2)

plot(26,26,'.','color',[1 1 1],'Markersize',26);



axis equal
box on
set(gca,'YTick',[5:10:46])
set(gca,'YTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])
set(gca,'XTick',[5:10:46])
set(gca,'XTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])

% text(0,53,strcat('(',letter{ii+8},')'),'Fontsize',10,'FontWeight','bold')
title('Anticyclonic Eddies','Fontsize',12)
clear nonzero







gca = colorbar('southoutside');
set(gca,'position',[0.175 0.1 0.65 0.02]); 
h = colorbar('horizon','position',[0.175 0.1 0.65 0.02]);set(h,'TickLength',0.035,'color',[0.99 1 1],'ticks',-0.5:0.05:0.5,'TickLabels',[],'LineWidth',1.5);
set(gca,'XTick',-0.5:0.1:0.5,'Fontsize',10)
caxis([-0.5 0.5])
set(get(gca,'Xlabel'),'string','(℃)');
set(gca,'Fontsize',10)
clear gca
clear nonzero



dif_double(10:11,:) = 0.955078
figure;set(gcf,'position',[0 0 400 500])
hold on
pcolor(nanmean(SST_meso_cyc_RCP85,3)-nanmean(SST_meso_cyc_Bhist,3));;shading interp;;xlim([2 50]);ylim([2 50]);caxis([-0.5 0.5]);colormap(flipud(dif_double));

plot(26,26,'.','color',[1 1 1],'Markersize',26);

[C,h] = contour(nanmean(SHF_meso_cyc_RCP85,3)-nanmean(SHF_meso_cyc_Bhist,3),2:2:10,'k','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

[C,h] = contour(nanmean(SHF_meso_cyc_RCP85,3)-nanmean(SHF_meso_cyc_Bhist,3),-10:2:-2,'k--','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

plot(x2+26,y2+26,'-','color',[ 1 1 1],'Linewidth',2)

plot(26,26,'.','color',[1 1 1],'Markersize',26);



axis equal
box on
set(gca,'YTick',[5:10:46])
set(gca,'YTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])
set(gca,'XTick',[5:10:46])
set(gca,'XTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])

box on
% text(0,53,strcat('(',letter{ii+8},')'),'Fontsize',10,'FontWeight','bold')
title('Cyclonic Eddies','Fontsize',12)
clear nonzero



gca = colorbar('southoutside');
set(gca,'position',[0.175 0.1 0.65 0.02]); 
h = colorbar('horizon','position',[0.175 0.1 0.65 0.02]);set(h,'TickLength',0.035,'color',[0.99 1 1],'ticks',-0.5:0.05:0.5,'TickLabels',[],'LineWidth',1.5);
set(gca,'XTick',-0.5:0.1:0.5,'Fontsize',10)
caxis([-0.5 0.5])
set(get(gca,'Xlabel'),'string','(℃)');
set(gca,'Fontsize',10)
clear gca
clear nonzero




r1=10; theta=0:pi/100:2*pi;
x1=r1*cos(theta); y1=r1*sin(theta);
r2=20; theta=0:pi/100:2*pi;
x2=r2*cos(theta); y2=r2*sin(theta);

letter = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h','i','j','k','l'}
load('dif_double.mat')
R = 1

dif_double(10:11,:) = 0.955078
figure;set(gcf,'position',[0 0 400 500])

pcolor(nanmean(SST_meso_anti_Bhist,3)-nanmean(SST_meso_cyc_Bhist,3));;shading interp;;xlim([2 50]);ylim([2 50]);caxis([-5 5]);colormap(flipud(dif_double));

plot(26,26,'.','color',[1 1 1],'Markersize',26);

[C,h] = contour(nanmean(SHF_meso_anti_Bhist,3)-nanmean(SHF_meso_cyc_Bhist,3),10:10:200,'k','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

[C,h] = contour(nanmean(SHF_meso_anti_Bhist,3)-nanmean(SHF_meso_cyc_Bhist,3),-200:10:-10,'k--','Linewidth',1.2);
clabel (C,h','fontsize',10,'color','k')%

plot(x2+26,y2+26,'-','color',[ 1 1 1],'Linewidth',2)

plot(26,26,'.','color',[1 1 1],'Markersize',26);




axis equal
box on
set(gca,'YTick',[6:10:46])
set(gca,'YTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])
set(gca,'XTick',[6:10:46])
set(gca,'XTickLabel',[{'-2R'} {'-R'} {'0'} {'R'} {'2R'} ])

% text(0,53,strcat('(',letter{ii+8},')'),'Fontsize',10,'FontWeight','bold')
title('Anticyclonic Eddies minus Cyclonic Eddies','Fontsize',12)
clear nonzero







gca = colorbar('southoutside');
set(gca,'position',[0.195 0.1 0.65 0.02]); 
h = colorbar('horizon','position',[0.195 0.1 0.65 0.02]);set(h,'TickLength',0.035,'color',[0.99 1 1],'ticks',-5:0.5:5,'TickLabels',[],'LineWidth',1.5);
set(gca,'XTick',-5:1:5,'Fontsize',10)
caxis([-5 5])
set(get(gca,'Xlabel'),'string','(℃)');
set(gca,'Fontsize',10)
clear gca
clear nonzero
text(-2.595,53.5,'a','FontSize',20,'FontWeight','bold')





%% Figure total Slope SHF
figure;set(gcf,'position',[0 0 400 400])
hold on
plot1 = line(grid_SST_meso_DJF_anti_regress_Bhist(1,:),Y_SST_SHF_anti_all_Bhist (1,:),'color','r','linewidth',2,'LineStyle','--')
% plot1.Color(4) = 0.01

plot1 = line(grid_SST_meso_DJF_anti_regress_RCP85(1,:),Y_SST_SHF_anti_all_RCP85 (1,:),'color',[139/255 26/255 26/255],'linewidth',2,'LineStyle','--')
plot1.Color(4) = 0.06
plot1 = line(grid_SST_meso_DJF_cyc_regress_Bhist(1,:),Y_SST_SHF_cyc_all_Bhist (1,:),'color','b','linewidth',2,'LineStyle','--')
% plot1.Color(4) = 0.01

plot1 = line(grid_SST_meso_DJF_cyc_regress_RCP85(1,:),Y_SST_SHF_cyc_all_RCP85 (1,:),'color',[25/255 25/255 112/255],'linewidth',2,'LineStyle','--')
plot1.Color(4) = 0.06
text(-2.5,60,['S(RCP) = ', num2str(round(p_SST_SHF_anti_RCP85(1,1),2))],'Fontsize',10,'color',[139/255 26/255 26/255])
text(0.5,-60,['S(RCP) = ', num2str(round(p_SST_SHF_cyc_RCP85(1,1),2))],'Fontsize',10,'color',[25/255 25/255 112/255])
text(-2.5,40,['S(HIS) = ', num2str(round(p_SST_SHF_anti_Bhist(1,1),2))],'Fontsize',10,'color','r')
text(0.5,-40,['S(HIS) = ', num2str(round(p_SST_SHF_cyc_Bhist(1,1),2))],'Fontsize',10,'color','b')
grid on
box on
axis tight
plot([0 0],[-80 80],'k--')
plot([-3 3],[0 0],'k--')
title('Coupling Coefficient of SST - SHF ','Fontsize',12)
clear gca
xlabel('(℃)')
ylabel('(W·m^-^2)')
set(gca,'Fontsize',10)

% text(-2,43,strcat('(',letter{1},')'),'Fontsize',10,'FontWeight','bold')
xlim([-3 3]);
ylim([-80 80])

set(gca,'Fontsize',10)

text(-3.995,87,'b','FontSize',20,'FontWeight','bold')
