function OUT = plumbplot3(X,Y,Z,varargin);
%PLUMBPLOT3 Plot points in 3D and projection lines onto the XY plane.
%A variation of PLOT3 that draws reference lines or plumb lines.
% PLUMBPLOT3(X,Y,Z) makes a plumb plot using the default line style.
% PLUMBPLOT3(X,Y,Z,S) using the line style S (see PLOT).
%
%Example:
% X1 = rand(9,1); Y1 = rand(9,1); Z1 = rand(9,1);
% X2 = rand(5,5); Y2 = rand(5,5); Z2 = rand(5,5);
% h1 = plumbplot3(X1,Y1,Z1,'bo:');
% hold on;
% h2 = plumbplot3(X2,Y2,Z2,'r*-.');
% hold off;
%Written by Daniel P. Dougherty (Oct, 24 1999)
%<dpdoughe@stat.ncsu.edu>
REPL = get(gca,'NextPlot');
X=X(:);
Y=Y(:);
Z=Z(:);
if (nargin == 4)
p1 = plot3(X,Y,Z,varargin{1});
set(p1,'LineStyle','none')
elseif (nargin == 3)
p1 = plot3(X,Y,Z,'bo');
end
hold on;
grid on;
A = axis;
if (nargin == 4)
for i =1:length(X)
plumb = plot3([X(i) X(i)] ,[Y(i) Y(i)],[A(5) Z(i)],varargin{1});
set(plumb,'Marker','none');
if strcmp(get(plumb,'LineStyle'),'none')
set(plumb,'LineStyle','-');
end
end
elseif (nargin == 3)
for i =1:length(X)
plot3([X(i) X(i)] ,[Y(i) Y(i)],[A(5) Z(i)],'b-');
end
end
hold off;
set(gca,'NextPlot',REPL)
OUT = gca;