function mortality_plus10_plot ()

%*****************************************************************************80
%
%% mortality_plus10_plot() plots the chance of living at least 10 more years.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 February 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mortality_plus10_plot():\n' );
  fprintf ( 1, '  Plot the probability of living at least 10 more years.\n' );
%
%  Get the data.
%
  [ age, total, male, female ] = mortality_count ( );

  n = length ( age );
%
%  Compute the total, male, and female death counts by summing the deaths.
%
  total_pop = sum ( total );
  male_pop = sum ( male );
  female_pop = sum ( female );
%
%  The number alive at age K is the population minus the number who have died 
%  up to that age.
%  (Mild off-by-one error here.)
%
  total_alive = total_pop - cumsum ( total );
  male_alive = male_pop - cumsum ( male );
  female_alive = female_pop - cumsum ( female );
%
%  The chance of being alive 10 years from now is the ratio between
%  the number of people like you alive in 10 years to the number of people
%  like you alive right now.
%
  total_10 = total_alive(11:n) ./ total_alive(1:n-10);
  total_10(n-9:n) = 0.0;

  male_10 = male_alive(11:n) ./ male_alive(1:n-10);
  male_10(n-9:n) = 0.0;

  female_10 = female_alive(11:n) ./ female_alive(1:n-10);
  female_10(n-9:n) = 0.0;
%
%  Draw the plot.
%
  figure ( );
  clf ( );
  hold ( 'on' );
    plot ( age, total_10, 'k-', 'linewidth', 3 );
    plot ( age, male_10, 'b-', 'linewidth', 3 );
    plot ( age, female_10, 'r-', 'linewidth', 3 );
  hold ( 'off' );
  xlabel ( '<-- Age now -->' );
  ylabel ( '<-- Probability -->' );
  title ( 'Probability of at least 10 more years of life' );
  legend ( 'Combined', 'Male', 'Female' );
  grid ( 'on' );

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

  close ( );

  return
end
