function hh = ribbon(varargin)
%RIBBON Draw 2-D lines as ribbons in 3-D.
%   RIBBON(X,Y) is the same as PLOT(X,Y) except that the columns of
%   Y are plotted as separated ribbons in 3-D.  RIBBON(Y) uses the
%   default value of X=1:SIZE(Y,1).
%
%   RIBBON(X,Y,WIDTH) specifies the width of the ribbons to be
%   WIDTH.  The default value is WIDTH = 0.75;  
%
%   H = RIBBON(...) returns a vector of handles to surface objects.
%
%   See also PLOT.

%   Clay M. Thompson 2-8-94
%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.13 $  $Date: 1997/11/21 23:46:42 $

error(nargchk(1,3,nargin));

% Parse input arguments.
if nargin<3, 
  width = .75;
  [msg,x,y] = xychk(varargin{1:nargin},'plot');
else
  width = varargin{3};
  [msg,x,y] = xychk(varargin{1:2},'plot');
end

if ~isempty(msg), error(msg); end

ax = newplot;
next = lower(get(ax,'NextPlot'));
hold_state = ishold;

[m,n] = size(y);
zz = [-ones(m,1) ones(m,1)]/2;
h = [];
cc = ones(size(y,1),2);
for i=1:size(y,2),
  h = [h;surface(zz*width+i,[x(:,i) x(:,i)],[y(:,i) y(:,i)],i*cc)];
end

if ~hold_state, view(3); grid on, set(ax,'NextPlot',next); end

if nargout>0, hh = h; end

