function Lims = findlims(DispAx,Type);

%   Author(s): K. Gondoly
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.9 $  $Date: 2000/06/14 19:59:09 $

% Minimum axis extent
MinExtent = 1e-5;

DispAx = DispAx(strcmp('on',get(DispAx,'visible')));
Lmin=[];
Lmax=[];

if ~isempty(DispAx)
   allLims = get(DispAx,{Type});
   allLims = cat(1,allLims{:});
   Lmin = min(allLims(:,1));
   Lmax = max(allLims(:,2));
end

if isempty(Lmin), % Lmin is empty if all systems are invisible
   Lmin = 0;
   Lmax = 1;
else
   Lc = (Lmin + Lmax)/2;
   MinGap = MinExtent*(1+abs(Lc));
   if abs(Lmax-Lmin)<MinGap,
      Lmin = Lc - MinGap;
      Lmax = Lc + MinGap;
   end
end

Lims = [Lmin Lmax];
