clear
close all
clc
format compact

yr = [2007,2010,2015,2020,2025,2030];

% w/o decay
[~, ~, raw] = xlsread('plot.xlsx','FigS1','B2:G6');
data1 = reshape([raw{:}],size(raw));

% w/ decay
[~, ~, raw] = xlsread('plot.xlsx','FigS1','B10:G14');
data2 = reshape([raw{:}],size(raw));


%% Figure S1: emission factors
figure(2); clf;
set(gcf, 'unit', 'centimeter', 'pos', [0.35   8.00   17.8    5]);

w = 0.1740;
h = 0.38;
x0 = 0.1930;
dx = 0.2445;
y1 = 0.59;
y2 = 0.09;

for i = 1:5
    switch i
        case 1
            ax1 = axes('pos', [x0    y1    w    h]); hold on; box on;
            ylabel('SO_2 (million ton)', 'color', 'k');
            ylim([0 75]);
            set(gca, 'ytick', 0:25:100);
        case 2
            ax2 = axes('pos', [x0+dx    y1    w    h]); hold on; box on;
            ylabel('NO_x (million ton)', 'color', 'k');
            ylim([0 75]);
            set(gca, 'ytick', 0:25:100);
        case 3
            ax3 = axes('pos', [x0+dx+dx    y1    w    h]); hold on; box on;
            ylabel('NH_3 (million ton)', 'color', 'k');
            ylim([0 30]);
        case 4
            ax1 = axes('pos', [x0+dx/2    y2    w    h]); hold on; box on;
            ylabel('BC (million ton)', 'color', 'k');
            ylim([0 4]);
        case 5
            ax1 = axes('pos', [x0+dx+dx/2    y2    w    h]); hold on; box on;
            ylabel('OC (million ton)', 'color', 'k');
            ylim([0 8]);
    end
    plot(yr, data1(i,:), 'ko-', 'markerf', 'w', 'markersize', 3);
    plot(yr, data2(i,:), 'ko-', 'markerf', 'k', 'markersize', 3);
    set(gca, 'fontsize', 5);
    xlim([2010 2030]);
    if i ==1
        [hO, hL] = legend('w/ Constant Emission Factors', 'w/ Time-Evolving Emission Factors');
        set(legend, 'pos', [0.1880    0.61    0.22    0.0905]);
        set(legend, 'edge', 'none');
        set(legend, 'color', 'none');
        set(hL(3), 'xdata', [0.0513 0.15])
        set(hL(4), 'xdata', 0.1)
        set(hL(5), 'xdata', [0.0513 0.15])
        set(hL(6), 'xdata', 0.1)
        set(hL(1), 'pos', [0.18    0.7013         0])
        set(hL(2), 'pos', [0.18    0.2987         0])
    end
    my_gridline;
end

annotation('textbox', [x0 0.88 0.2 0.1], 'String', '(a)', 'linestyle', 'none', 'fontweight', 'bold');
annotation('textbox', [x0+dx 0.88 0.2 0.1], 'String', '(b)', 'linestyle', 'none', 'fontweight', 'bold');
annotation('textbox', [x0+dx+dx 0.88 0.2 0.1], 'String', '(c)', 'linestyle', 'none', 'fontweight', 'bold');
annotation('textbox', [x0+dx/2 0.375 0.2 0.1], 'String', '(d)', 'linestyle', 'none', 'fontweight', 'bold');
annotation('textbox', [x0+dx+dx/2 0.375 0.2 0.1], 'String', '(e)', 'linestyle', 'none', 'fontweight', 'bold');

%%
set(hL(1),'fontsize',5)
set(hL(2),'fontsize',5)

