function tracks_bar ( )

%*****************************************************************************80
%
%% TRACKS_BAR averages several eye track datafiles and bar plots them.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    08 May 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'TRACKS_BAR:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Read multiple text files containing durations\n' );
  fprintf ( 1, '  representing results of an eye-tracking experiment.\n' );
  fprintf ( 1, '  Average the data.\n' );
  fprintf ( 1, '  Make a bar plot of the results, with labeled bars.\n' );
%
%  Set the labels.
%  For an array of text strings, we need to use a cell array,
%  delimited by '{' and '}'.
%
  labels = {
    'anger',
    'disgust',
    'fear',
    'happy',
    'sad',
    'surprise' };
%
%  Read the data files.
%
  directory = pwd;
  files = dir ( fullfile ( directory, 'tracks*_data.txt' ) );
  file_num = length ( files );

  duration = zeros ( 6, 1 );

  for k = 1 : file_num
    short_name = files(k).name;
    data = load ( short_name );
    duration = duration + data;
  end
%
%  Average the data.
%
  duration = duration / file_num;
%
%  Make a bar plot.
%
  bar ( duration )
  set ( gca, 'xticklabel', labels );
  grid ( 'on' )
  xlabel ( '<-- Eye Region -->', 'FontSize', 16 )
  ylabel ( '<-- Duration (msec) -->', 'FontSize', 16 )
  title ( 'Fixation Duration (Averaged)', 'FontSize', 20 )
%
%  Force the Y axis to 2100.
%
  ylim ( [ 0, 2100 ] )
%
%  Save a snapshot of the plot.
%
  filename = 'tracks_bar.png';
  print ( '-dpng', filename )
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'TRACKS_BAR:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
