function []= stkplot(pltnum, maxnum, x, y, ltype, peg)
%	Plot data on stack axis.
%
%	function []= stkplot(pltnum, maxnum, x, y[, ltype, peg])
%	  pltnum= plot number counting bottom up {scaler}
%	  maxnum= total number of plots per page {scaler}
%	  x= {vector}
%	  y= {vector}
%	  ltype= line (or symbol) type (optional default= stkdc)
%	  peg= if 'n', then don't peg the data (default= 'y')

%	Latest revision by P. Dragos 21-May-91.
%
%	P. Dragos, Battelle Ocean Sciences
%	Duxbury, MA 02332
%	(617) 934-0571
%
%	Copyright (c) 1991 by Paul Dragos.
%	This program is copyrighted.  However, you are encouraged to
%	copy and share it, so long as no charge is imposed.

%				---------------------------------------
%				defaults from stkparm.mat
load stkparm.mat
x0= stkx0; y0= stky0; x1= stkx1; y1= stky1;
sep= stksep; c= stkc; dc= stkdc;
ax= stkax(pltnum,:);
%				---------------------------------------
%				defaults
if nargin == 5, 
  if (ltype == 'y' | ltype == 'n'),  peg= ltype;  ltype= dc;  
  else peg= 'y';
  end;
end;
if nargin < 5,  ltype= dc;  peg= 'y';  end;

%				---------------------------------------
%				calculate axis boundaries
yaxl= (((y1-y0)-sep)/maxnum)-sep;
xaxl= x1-x0;
ystr= ((pltnum-1)*(yaxl+sep))+sep;
xstr= x0;
%				---------------------------------------
%				Peg the data
if (peg=='y'),
  ii= find(y > ax(4));
  jj= find(y < ax(3));
  nn= size(ii);
  mm= size(jj);
  if (length(ii) ~= 0), y(ii)= ax(4)*ones(nn(1),nn(2)); end;
  if (length(jj) ~= 0), y(jj)= ax(3)*ones(mm(1),mm(2)); end;
end;
%				---------------------------------------
%				Scale the data
yscale= yaxl / (ax(4) - ax(3));
yp= (yscale .* (y - ax(3))) + ystr;

xscale= xaxl / (ax(2) - ax(1));
xp= (xscale .* (x - ax(1))) + xstr;

plot(xp, yp, ltype);

