% eda02_06
% computes and plot histogram two ways, as
% a graph and as a grey scale column-vector

% read the data
D=load('brf_temp.txt');
t=D(:,1);
d=D(:,2);
Ns=size(D);
N=Ns(1);
M=Ns(2);

% create histogram
Lh = 100;
dmin = min(d);
dmax = max(d);
bins = dmin + (dmax-dmin)*[0:Lh-1]'/(Lh-1);
dhist = hist(d, bins)';

figure(1);
clf;

subplot(1,2,1);
set(gca,'LineWidth',2);
hold on;
axis ij;
plot(dhist, bins, 'k','LineWidth',2);
title('Histogram of temperature');
xlabel('tempeature bin');
ylabel('counts');

subplot(1,2,2);
set(gca,'LineWidth',2);
axis([0, 1, 0, 1]);
hold on;
axis ij;
axis off;

% create grey-scale color map
bw=0.9*(256-[0:255]')/256;
colormap([bw,bw,bw]);

% plot the vector dhist

imagesc( [0.4, 0.6], [0, 1], dhist);
text(0.66,-0.2,'dhist');

colorbar('vert');
