function nile_histogram ( )

%*****************************************************************************80
%
%% NILE_HISTOGRAM plots a histogram of yearly flood levels for the Nile.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 July 2018
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'NILE_HISTOGRAM:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  Make a histogram of yearly Nile flood levels.\n' );

  data = load ( 'nile_data.txt' );

  [ m, n ] = size ( data );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d x %d data records read from file.\n', m, n );
%
%  Create a histogram.
%
  bin_min = min ( data(:,2) );
  bin_max = max ( data(:,2) );
  bin_num = 20;
 
  [ bin_ave, bin_count ] = histogramize ( m, data(:,2), bin_min, bin_max, bin_num );

  bar ( bin_ave, bin_count );
  grid on
  xlabel ( '<-- Height of Nile at Maximum Flood -->' )
  ylabel ( '<-- Frequency -->' )
  title ( 'Yearly Nile Flood Height' )

  pause ( 5 )
%
%  Save graphics in file.
%
  filename = 'nile_histogram.png';
  print ( '-dpng', filename )
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'NILE_HISTOGRAM:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  return
end

