clear;
close all;
clc;
format compact;

set_list;
%% CO2
[~, ~, raw] = xlsread('plot.xlsx','4 pct','H3:I32');
data = reshape([raw{:}],size(raw));
co2_r_2030_bau = data(:,1);
co2_r_2030_p4 = data(:,2);
clearvars data raw;

%% Anthoprogenic PM2.5
[~, ~, raw] = xlsread('plot.xlsx','4 pct','T3:U32');
data = reshape([raw{:}],size(raw));
pm_anth_r_2030_bau = data(:,1);
pm_anth_r_2030_p4 = data(:,2);
clearvars data raw;

%% Totoal PM2.5 (anth. PM + other sources)
[~, ~, raw] = xlsread('plot.xlsx','4 pct','V3:W32');
data = reshape([raw{:}],size(raw));
pm_total_r_2030_bau = data(:,1);
pm_total_r_2030_p4 = data(:,2);
clearvars data raw;

%% Figure S5: anth PM change vs. CO2 change & total PM change vs. CO2 change
figure(1); clf; hold on; box on;
set(gcf, 'unit', 'centimeter', 'pos', [1    4.5   17.8    8]);

x = (co2_r_2030_bau - co2_r_2030_p4)./co2_r_2030_bau*100;
y = (pm_anth_r_2030_bau - pm_anth_r_2030_p4)./pm_anth_r_2030_bau*100; % anth PM
y2 = (pm_total_r_2030_bau - pm_total_r_2030_p4)./pm_total_r_2030_bau*100; % total PM

plot([0 40], [0 40], '--', 'color', [1 1 1]*0.7);
text(13, 13.7, 'One-to-One Ratio Line', 'color', [1 1 1]*0.7, 'rotation', 45, 'fontsize', 7);

for i = 1:30
    plot([1 1]*x(i), [y(i), y2(i)-0.1], 'color', [1 1 1]*0.6, 'linewidth', 0.5);
end
h1 = plot(x, y, 'o', 'color', [1 1 1]*0.7, 'markersize', 4);
h2 = plot(x, y2, 'ko', 'markerf', 'k', 'markersize', 4);

grid on;
set(gca, 'fontsize', 7);
xlabel('\DeltaCO_2 (%)');
ylabel('\DeltaPM_{2.5} (%)');
legend([h1, h2], 'Anthropogenic PM_{2.5}', 'Total PM_{2.5}');
set(legend, 'location', 'southwest');

axis equal;
xlim([0 55]);
ylim([0 30]);
set(gca, 'pos', [0.08    0.12    0.86    0.85]);
set(gca, 'xtick', 0:5:55);
set(gca, 'ytick', 0:5:40);

for i = 1:length(x)
    % top
    if any(ismember({'HA','CQ','AH','SD','SN','HB'}, r2{i}))
        text(x(i)-1.2, y(i)+0.2, ['  ', r2{i}, '  '], 'verticalalignment', 'bottom', 'fontsize', 6);    
    % top right
    elseif any(ismember({'HE'}, r2{i}))
        text(x(i), y(i), ['  ', r2{i}, '  '], 'horizontalalignment', 'left', 'fontsize', 6);
    % bottom right
    elseif any(ismember({'JS','JX','TJ','SC'}, r2{i}))
        text(x(i)-0.1, y2(i), ['  ', r2{i}, '  '], 'horizontalalignment', 'left', 'fontsize', 6);
    % bottom
    else
        text(x(i)-1.2, y2(i)-0.2, ['  ', r2{i}, '  '], 'verticalalignment', 'top', 'fontsize', 6);    
    end
end