function pwc_patch_1d ( x, y )

%*****************************************************************************80
%
%% pwc_patch_1d() plots a piecewise constant function of X as color patches.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X(N+1), the breakpoint coordinates, in ascending order.
%
%    real Y(N), the interval values.
%
  x = x(:);
  y = y(:);
  n = size ( y, 1 );

  x_range = max ( x ) - min ( x );
  yp1 = -0.1 * x_range;
  yp2 =  0.1 * x_range;
  yp = [ yp1, yp1, yp2, yp2 ];

  figure ( );

  for i = 1 : n
    xp = [ x(i), x(i+1), x(i+1), x(i) ];
    patch ( xp, yp, y(i), 'EdgeColor', 'k' );
  end

  xlabel ( '<--- X --->', 'fontsize', 12 );
  datestring = datestr ( datevec ( now ), 0 );
  title ( { 'pwc patch 1d'; datestring }, 'fontsize', 16 );
  axis ( 'equal' );
  axis ( 'tight' );
  colormap ( 'jet' );
  colorbar ( 'southoutside' );
  set ( gca, 'ytick', [] );
  filename = 'pwc_patch_1d.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved as "%s".\n', filename );

  return
end
