function coin_average_plot ( n, v, label, filename )

%*****************************************************************************80
%
%% coin_average_plot() plots the running average of N coin tosses.
%
%  Discussion:
%
%    Note that this function does not call CLF to clear the figure.
%    Therefore, invoking the function twice in a row will
%    show both the old and new plots together.  This operation can be
%    repeated.  Since we expect the plots to show similar behavior
%    towards the right, this may be a useful feature.  If not,
%    call clf, or uncomment the "clf" below.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 September 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of tosses.
%
%    real V(N), the toss results, -1 or +1.
%
%    string LABEL, a label for the plot.
%
%    string FILENAME, a name for the plot file.
%
  a = r8vec_running_average ( n, v );

  ip1 = 1 : n + 1;
%
%  Uncomment this "CLF" if you want to guarantee the plot
%  appears on a new plot figure.
%
  clf ( );
  hold ( 'on' );
  plot ( ip1, a, 'b.-', 'MarkerSize', 25, 'LineWidth', 2 );
  xlabel ( '<-- Tosses -->', 'FontSize', 16 );
  ylabel ( 'Running Average', 'FontSize', 16 );
  title ( label );
  limits = axis;
  limits(3) = -1.1;
  limits(4) = +1.1;
  axis ( limits );
  hold ( 'off' );

  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
