%% Open data file
dataf3_1 = readtable('Fig3_1.csv');
dataf3_2 = readtable('Fig3_2.csv');
dataf3_3 = readtable('Fig3_3.csv');
timef4_1 = duration(dataf3_1.EventDays(1:end),"InputFormat","hh:mm");
%% Call new figure
figure("Position",[747,365,897,346])
tile_formrate = tiledlayout(1,3,'TileSpacing','compact','Padding','compact');
%% Plot the first subplot
nexttile(1)
b1 = bar(timef4_1,dataf3_1{:,2:4},'stacked','LineStyle','none','BarWidth',1);
hold on
lin1 = plot(timef4_1,dataf3_1{:,5},'k','LineWidth',2.3);
b1(1).FaceColor = [.87 .67 .20];
b1(2).FaceColor = [.73 .33 .40];
b1(3).FaceColor = [.0 .27 .53];
text(-0.26,0.97,'(a)','Units','normalized','FontSize',16,'FontWeight','bold');
title('Event Days'),%set(gca,'XTick',0:3:24,'box','off')
grid on
xticklabels({'0','3','6','9','12','15','18','21','24'})
xticks(hours(0:3:24))
xlim([hours(0) hours(24)])
ylim([-2.75 5.25])
ylabel('J_{10} (cm^-^3 h^-^1)')
xlab1 = xlabel('Local Time (h)');
xlab1.FontSize = 14;
xtickangle(0)
yticks(-3:5)

%% Plot the second subplot
nexttile(2)
b2 = bar(timef4_1,dataf3_1{:,6:8},'stacked','LineStyle','none','BarWidth',1);
hold on
lin2 = plot(timef4_1,dataf3_1{:,9},'k','LineWidth',2.3);
b2(1).FaceColor = [.87 .67 .20];
b2(2).FaceColor = [.73 .33 .40];
b2(3).FaceColor = [.0 .27 .53];
text(-0.26,0.97,'(b)','Units','normalized','FontSize',16,'FontWeight','bold');
title('Non-Event Days'),%set(gca,'XTick',0:3:24,'box','off')
grid on
xticks(hours(0:3:24))
xlim([hours(0) hours(24)])
xticklabels({'0','3','6','9','12','15','18','21','24'})
ylim([-2.75 5.25])
ylabel('J_{10} (cm^-^3 h^-^1)')
xlab1 = xlabel('Local Time (h)');
xlab1.FontSize = 14;
xtickangle(0)
yticks(-3:5)
legend('dN/dt','Coag.','Growth','Total','Box','off')

%% Plot the third subplot
nexttile(3)
boxpatch(dataf3_2{:,2},dataf3_3{:,2},{'Event Days','Non-event days'})
ylabel('DPR_{10} (cm^-^3 day^-^1)')
grid on
ax=gca;
set(ax,'GridLineStyle',':','XGrid','off')
text(-0.33,0.97,'(c)','Units','normalized','FontSize',16,'FontWeight','bold');
xlim([0.7 2.3])
set(ax,'YScale','log')
xtickangle(0)
ylim([6 400])
yticks([10 30 60 100 300])
title('Daily Production Rate')