%%% Histogram for growth_rate %%%%%%%%
mat1=dlmread('wm_km_growth_rate.csv',' ');
mat1=-mat1;
j=1;
freqs1=1:20;
for i=-0.3:0.02:0.08
 gather=((mat1>i) & (mat1<(i+0.02)));
 freqs1(j)=length(mat1(gather,:));
 j=j+1;
end
mat1range=-0.3:0.02:0.1;

mat2=dlmread('wr_kr_growth_rate.csv',' ');
mat2=-mat2;
j=1;
freqs2=1:20;
for i=-0.3:0.02:0.08
 gather=((mat2>i) & (mat2<(i+0.02)));
 freqs2(j)=length(mat2(gather,:));
 j=j+1;
end

mat3=dlmread('wm_wmn_lag_time.csv',' ');
mat3=-mat3;
j=1;
freqs3=1:20;
for i=-0.3:0.02:0.08
 gather=((mat3>i) & (mat3<(i+0.02)));
 freqs3(j)=length(mat3(gather,:));
 j=j+1;
end

%%%%%%% Histogram for max OD %%%%%%%%%
mat1=dlmread('wm_km_global_max_od.csv',' ');
mat1=-mat1;
j=1;
freqs1=1:20;
for i=-0.655:0.045:0.2
 gather=((mat1>i) & (mat1<(i+0.045)));
 freqs1(j)=length(mat1(gather,:));
 j=j+1;
end
mat1range=-0.7:0.045:0.2;

mat2=dlmread('wr_kr_global_max_od.csv',' ');
mat2=-mat2;
j=1;
freqs2=1:20;
for i=-0.655:0.045:0.2
 gather=((mat2>i) & (mat2<(i+0.045)));
 freqs2(j)=length(mat2(gather,:));
 j=j+1;
end


nfreqs=horzcat(freqs1',freqs2');

%%%% overlayed version of bar plot %%%%%%
barWidth=0.8; %1.1
bar1=bar(mat1range(2:21),freqs1,barWidth);
set(bar1,'FaceColor','b','EdgeColor','w');
hold on;
barWidth=0.4; %0.7
bar2=bar(mat1range(2:21),freqs2,barWidth);
set(bar2,'FaceColor','r','EdgeColor','w');
hold off;

%%%% grouped version of bar plot %%%%%%%
bar(mat1range(2:21),nfreqs,1.6); % number here is bar width
%cmat=[[0 0 1]; [1 0 0]];       % blue and red defined in RGB
%cmat=[[0 1 0]; [1 1 0]];       % green and yellow defined in RGB
colormap(cmat);       

%%%% for both versions %%%%%%%%
legend_handle=legend('k-w in minimal','k-w in rich',2);
set(legend_handle,'FontSize',14);
xlabel('OD increase per hour','fontsize',16);
ylabel('Frequency counts','fontsize',16);
line([0 0],[0 16],[0 0],'Color','k','LineStyle','--','LineWidth',2,'Marker','none');
set(gca,'xlim',[-0.3 0.1])
set(gca,'XTick',[-0.3:0.1:0.1]);
set(gca,'XTickLabel',{'-0.3';'-0.2';'-0.1';'0';'0.1'});
set(gca,'YTick',[4 8 12 16]);
set(gca,'YTickLabel',{'4';'8';'12';'16'});
set(gca,'XTickMode','manual','YTickMode','manual')
set(gca,'FontName','FixedWidth');
set(gca,'FontSize',16);
set(gca,'FontWeight','b');
set(gca,'TickLength',[0.03 0]);

%%%%% for global_max_od %%%%%%%
legend_handle=legend('k-w in minimal','k-w in rich',2);
set(legend_handle,'FontSize',14);
xlabel('max OD measurement','fontsize',16);
ylabel('Frequency counts','fontsize',16);
line([0 0],[0 16],[0 0],'Color','k','LineStyle','--','LineWidth',2,'Marker','none');
set(gca,'xlim',[-0.7 0.2])
set(gca,'XTick',[-0.6:0.2:0.2]);
set(gca,'XTickLabel',{'-0.6';'-0.4';'-0.2';'0';'0.2'});
set(gca,'YTick',[4 8 12 16]);
set(gca,'YTickLabel',{'4';'8';'12';'16'});
set(gca,'XTickMode','manual','YTickMode','manual')
set(gca,'FontName','FixedWidth');
set(gca,'FontSize',16);
set(gca,'FontWeight','b');
set(gca,'TickLength',[0.03 0]);


%%% overlayed version of bar plot %%%%%
fname='overlayed_growth_rate0.8.tiff';
saveas(gcf,fname,'tiff');

%%%%% grouped version of bar plot %%%%
fname='grouped_growth_rate1.6.tiff';
saveas(gcf,fname,'tiff');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


