clear all
load result_baseline_3prm.mat

%% Figure 9: variance decomposition %%

var1 = figure;
hold on
plot(var_q(:,1),'-o','LineWidth',2,'Color',[0 0 0]) % black
plot(var_q(:,2),'-','LineWidth',2,'Color',[1 0 0]) % red
plot(var_q(:,3),'-p','LineWidth',2,'Color',[1 0 1]) % magenta
plot(var_q(:,4),'--','LineWidth',3,'Color',[0 0 0]) % magenta
plot(var_q(:,1)-2*std_all(:,1),':','LineWidth',3,'Color',[0 0 0]) % black
plot(var_q(:,1)+2*std_all(:,1),':','LineWidth',3,'Color',[0 0 0]) % black
plot(var_q(:,2)-2*std_all(:,2),':','LineWidth',3,'Color',[1 0 0]) % red
plot(var_q(:,2)+2*std_all(:,2),':','LineWidth',3,'Color',[1 0 0]) % red
plot(var_q(:,3)-2*std_all(:,3),':','LineWidth',3,'Color',[1 0 1]) % magenta
plot(var_q(:,3)+2*std_all(:,3),':','LineWidth',3,'Color',[1 0 1]) % magenta
plot(var_q(:,4)-2*std_all(:,4),':','LineWidth',3,'Color',[0 0 0]) % magenta
plot(var_q(:,4)+2*std_all(:,4),':','LineWidth',3,'Color',[0 0 0]) % magenta
axis([1,48,0,1])
hleg1 = legend('W_L','W_H','P_L^{ux}','P_H^{ux}');
set(hleg1,'Location','Northeast') 
colorstr=[159 182 205]/256;
hold off
saveas(var1,'Figure9_a','epsc');% change this

var2 = figure;
hold on
plot(var_io(:,1),'--','LineWidth',2,'Color',[0 0 0]) % black
plot(var_io(:,2),'-','LineWidth',2,'Color',[1 0 0]) % red
plot(var_io(:,1)+2*stdev_inout(:,1),':','LineWidth',3,'Color',[0 0 0]) % black
plot(var_io(:,1)-2*stdev_inout(:,1),':','LineWidth',3,'Color',[0 0 0]) % black
plot(var_io(:,2)+2*stdev_inout(:,2),':','LineWidth',3,'Color',[1 0 0]) % black
plot(var_io(:,2)-2*stdev_inout(:,2),':','LineWidth',3,'Color',[1 0 0]) % black
axis([1,48,0,1])
hleg1 = legend('Inflows','Outflows');
set(hleg1,'Position', [0.2,0.8,0.1,0.1]) 
colorstr=[159 182 205]/256;
hold off
saveas(var2,'Figure9_b','epsc');

var3 = figure;
hold on
plot(var_HL(:,1),'--','LineWidth',2,'Color',[1 0 0]) % black
plot(var_HL(:,2),'-','LineWidth',2,'Color',[0 0 0]) % red
plot(var_HL(:,1)+2*stdev_type(:,1),':','LineWidth',3,'Color',[1 0 0]) % black
plot(var_HL(:,1)-2*stdev_type(:,1),':','LineWidth',3,'Color',[1 0 0]) % black
plot(var_HL(:,2)+2*stdev_type(:,2),':','LineWidth',3,'Color',[0 0 0]) % black
plot(var_HL(:,2)-2*stdev_type(:,2),':','LineWidth',3,'Color',[0 0 0]) % black
axis([1,48,0,1])
hleg1 = legend('L','H');
set(hleg1,'Position', [0.75,0.7,0.1,0.1]) 
colorstr=[159 182 205]/256;
hold off
saveas(var3,'Figure9_c','epsc');

