function NewLims = setlims(Editor,XlimData,YlimData,AxisNumber)
%SETLIMS  Set axes limits & editor limmodes
 
%   Author(s): A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.3 $  $Date: 2000/07/31 16:04:06 $

%---Default y-axis is magnitude (1)
if nargin<4, 
	AxisNumber = 1; 
end

%---Apply new x-axis limits
if ~isempty(XlimData)
	if ischar(XlimData)
		Editor.XlimMode = {XlimData};
	else
		Editor.XlimMode = {'manual'};
		set(Editor.HG.PlotAxes(:),'XLim',XlimData);
	end
end

%---Apply new y-axis limits
if ~isempty(YlimData)
	if ischar(YlimData)
		YlimMode = Editor.YlimMode;
		YlimMode{AxisNumber} = YlimData;
		Editor.YlimMode = YlimMode;
	else
		YlimMode = Editor.YlimMode;
		YlimMode{AxisNumber} = 'manual';
		Editor.YlimMode = YlimMode;
		set(Editor.HG.PlotAxes(AxisNumber),'YLim',YlimData);
	end
end

%---Update
updatelims(Editor);

%---Get new limits (updatelims may adjust limits if AxesEqual is on)
Lims = get(Editor.HG.PlotAxes(AxisNumber),{'XLim','YLim'});
NewLims = [Lims{:}];
