function [ xp, yp ] = pwc2_plot ( x, y )

%*****************************************************************************80
%
%% pwc2_plot() defines the lines forming a piecewise constant plot.
%
%  Discussion:
%
%    Given X1, Y1, X2, Y2, X3, ..., XN, YN, XN+1
%
%    such that F(X) = Y(I) for XI <= X <= XI+1, we can plot
%    this piecewise constant function by asking MATLAB to plot
%    a sequence of 3*N+1 points (XP,YP).
%
%    This version of the function draws the "seams" between neighboring bars.
%
%               +-+
%        +------+ |
%        |      | |
%    +---+      | +---+
%    |   |      | |   |
%    +   +      + +   +
%
%    N = 4, uses 13 points.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 August 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X(N+1), the break points.
%
%    real Y(N), the function values.
%
%  Output:
%
%    real XP(3*N+1), YP(3*N+1), a sequence of points that
%    define the piecewise constant plot.
%
  n = length ( y );

  xp = zeros ( 3 * n + 1, 1 );
  yp = zeros ( 3 * n + 1, 1 );

  k = 0;

  for i = 1 : n

    if ( i == 1 )
      k = k + 1;
      xp(k) = x(i);
      yp(k) = 0.0;
    end

    k = k + 1;
    xp(k) = x(i);
    yp(k) = y(i);

    k = k + 1;
    xp(k) = x(i+1);
    yp(k) = y(i);

    k = k + 1;
    xp(k) = x(i+1);
    yp(k) = 0.0;

  end

  return
end

