0001 function AdjustAxes(f,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 xlims = [];
0036 ylims = [];
0037
0038
0039 if nargin < 1,
0040 f = gcf;
0041 elseif ischar(f),
0042 varargin = {f,varargin{:}};
0043 f = gcf;
0044 elseif ~ishandle(f),
0045 error('Incorrect value for ''f'' (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).');
0046 end
0047
0048
0049 for i = 1:2:length(varargin),
0050 if ~ischar(varargin{i}),
0051 error(['Parameter ' num2str(i+1) ' is not a property (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).']);
0052 end
0053 switch(lower(varargin{i})),
0054 case 'x',
0055 xlims = lower(varargin{i+1});
0056 if ~isdvector(xlims,'<') && ~isastring(xlims,'auto','uniform'),
0057 error('Incorrect value for property ''xlims'' (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).');
0058 end
0059 case 'y',
0060 ylims = lower(varargin{i+1});
0061 if ~isdvector(ylims,'<') && ~isastring(ylims,'auto','uniform'),
0062 error('Incorrect value for property ''ylims'' (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).');
0063 end
0064 case 'xy',
0065 xlims = lower(varargin{i+1});
0066 ylims = lower(varargin{i+1});
0067 if ~isdvector(xlims,'<') && ~isastring(xlims,'auto','uniform'),
0068 error('Incorrect value for property ''AdjustAxess'' (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).');
0069 end
0070 otherwise,
0071 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help AdjustAxes">AdjustAxes</a>'' for details).']);
0072 end
0073 end
0074
0075 if isempty(xlims) && isempty(ylims),
0076 xlims = 'uniform';
0077 ylims = 'uniform';
0078 end
0079
0080
0081 sub = get(f,'children');
0082 if strcmp(xlims,'uniform'),
0083 lims = [];
0084 for i = 1:length(sub),
0085 if strcmp(get(sub,'type'),'axes'),
0086 lims(end+1,:) = xlim(sub(i));
0087 end
0088 end
0089 if isempty(lims), return; end
0090 xlims = [min(lims(:,1)) max(lims(:,2))];
0091 end
0092 if strcmp(ylims,'uniform'),
0093 lims = [];
0094 for i = 1:length(sub),
0095 if strcmp(get(sub,'type'),'axes'),
0096 lims(end+1,:) = ylim(sub(i));
0097 end
0098 end
0099 if isempty(lims), return; end
0100 ylims = [min(lims(:,1)) max(lims(:,2))];
0101 end
0102
0103
0104 for i = 1:length(sub),
0105 if strcmp(get(sub,'type'),'axes'),
0106 if strcmp(xlims,'auto'),
0107 xlim(sub(i),'auto');
0108 elseif ~isempty(xlims),
0109 xlim(sub(i),xlims);
0110 end
0111 if strcmp(ylims,'auto'),
0112 ylim(sub(i),'auto');
0113 elseif ~isempty(ylims),
0114 ylim(sub(i),ylims);
0115 end
0116 end
0117 end