function geyser_bar ( )

%*****************************************************************************80
%
%% GEYSER_BAR uses MATLAB to make a bar plot.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    28 April 2011
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'GEYSER_BAR\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Create a bar plot of the time between eruptions\n' );
  fprintf ( 1, '  of the Old Faithful geyser.\n' );
  fprintf ( 1, '  To do this, we take a data set and preprocess it\n' );
  fprintf ( 1, '  into bins that we choose.\n' );
%
%  Load the data.
%
  t = load ( 'geyser_data.txt' );
%
%  Our data lies in the range 40 to 110.
%  Dividing into bins of width 2, we want 35 bins.
%  But that means 35+1 "edges".
%
  bin_num = 35;
  bin_edges = linspace ( 40.0, 110.0, bin_num + 1 );
%
%  T_BINNED counts data between successive bin edges.
%
  t_binned = histc ( t, bin_edges );
%
%  Discard the last entry, which counts data greater than the last bin edge.
%
  t_binned = t_binned(1:bin_num);
%
%  Set the average value of each bin.  
%
  bar_center = linspace ( ( bin_edges(1)     + bin_edges(2)    ) / 2, ...
                          ( bin_edges(end-1) + bin_edges(end) ) / 2, ...
                          bin_num );
%
%  Set the relative width of the bar.
%
  bar_width = 0.80;
%
%  Draw a bar graph.
%
  bar ( bar_center, t_binned, bar_width, 'r' );

  grid on
  title ( 'Time between eruptions of Old Faithful' )
  xlabel ( 'Minutes' )
  ylabel ( 'Frequency' )
%
%  Save a copy of the plot as a PNG file.
%
  filename = 'geyser_bar.png';
  print ( '-dpng', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'GEYSER_BAR:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
