% Plot 4 subplots for s300 flood
% Subplot 1 - Total area vs ln(attenuation)
% Subplot 2 - Fraction inundated at baseflow vs ln(attenuation)
% Subplot 3 - Multiple linear regression (w/1&2) vs ln(attenuation)
% Subplot 4 - Multiple linear regression (1 or 2) vs ln(attenuation)

clear

% Set colors
cmap = lines;
marker_color = cmap(1,:);
line_color = cmap(2,:);

% Load data

dir_root = ['/Users/Colin/Documents/MATLAB/DFlow/'...
    'influences_chap2/transform/'];

% Load s300 flood characteristics
load(strcat(dir_root,'matrix_lny_x_300.mat'));

% Load ln(attenuation) data
load(strcat(dir_root,'ln_y300_matrix.mat'));
load(strcat(dir_root,'qar_rate1000s300.mat'));

lny300 = ln_y300_matrix;

% Plot
f1 = figure(1);
set(f1,'color','white');

subplot(2,2,1);
mdl1 = fitlm(matrix_lny_x_300(:,1),lny300);
sp1 = plot(mdl1);
set(sp1(1), 'MarkerEdgeColor', marker_color);
set(sp1(2), 'Color',  line_color);
set(sp1(3),'Color', line_color);
set(sp1(4),'Color', line_color);
hold on 
ylabel('ln(\DeltaQAR)','Interpreter','tex');
xlabel('TA (km^2)','Interpreter','tex');
xlim([0.3 0.8]);
set(gca,'Fontsize',14);
legend('off')
title('')

subplot(2,2,2);
mdl6 = fitlm(matrix_lny_x_300(:,6),lny300);
sp2 = plot(mdl6);
set(sp2(1), 'MarkerEdgeColor', marker_color);
set(sp2(2), 'Color',  line_color);
set(sp2(3),'Color', line_color);
set(sp2(4),'Color', line_color);
xlim([0.2 1]);
xticks([0.2 0.4 0.6 0.8 1.0]);
xlabel('RIATA','Interpreter','tex');
ylabel('');
set(gca,'Fontsize',14);
legend('off')
title('')

subplot(2,2,3);
mdl136 = fitlm(matrix_lny_x_300(:,[1 3 6]),lny300);
plot(mdl136);
xlim([-0.6 0.2]);
xticks(-0.6:0.2:0.2);
ylabel('ln(\DeltaQAR)','Interpreter','tex');
xlabel({'TA, BCE, RIATA';'Predictor Model'});
set(gca,'Fontsize',14);
legend('off')
title('')

subplot(2,2,4);
mdl346 = fitlm(matrix_lny_x_300(:,[3 4 6]),lny300);
plot(mdl346);
xlim([-1.2 -0.4]);
xticks(-1.2:0.2:-0.4);
xlabel({'BCE, WSE-BE, RIATA';'Predictor Model'});
ylabel('');
set(gca,'Fontsize',14);
legend('off')
title('')

% mdl634 = fitlm(matrix_lny_x_300(:,[6 3 4]),lny300)
% mdl634 = fitlm(matrix_lny_x_300(:,[6 3]),lny300)

% f2=figure(2);
% plot(mdl136);

% ylabel('ln(delta QAR)');
% xlabel('X1, X3, X6');
% set(gca,'Fontsize',14);
% legend('off')
% title('')

