-
Notifications
You must be signed in to change notification settings - Fork 3
/
spm_axis.m
35 lines (31 loc) · 1.02 KB
/
spm_axis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# SPDX-License-Identifier: GPL-2.0
function varargout = spm_axis(varargin)
% AXIS Control axis scaling and appearance.
if nargout
[varargout{1:nargout}] = axis(varargin{:});
else
try
axis(varargin{:});
end
end
if nargin == 1 && any(strcmpi(varargin{1},{'tight','scale'}))
spm_axis(gca,varargin{1});
elseif nargin == 2 && allAxes(varargin{1}) && strcmpi(varargin{2},'tight')
for i = 1:numel(varargin{1})
lm = get(varargin{1}(i),'ylim');
if diff(lm) < 1e-12
set(varargin{1}(i),'ylim',lm + [-1 1]);
else
set(varargin{1}(i),'ylim',lm + [-1 1]*diff(lm)/16);
end
end
elseif nargin == 2 && allAxes(varargin{1}) && strcmpi(varargin{2},'scale')
for i = 1:numel(varargin{1})
lm = get(varargin{1}(i),'ylim');
set(varargin{1}(i),'ylim',[0 lm(2)*(1 + 1/16)]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result = allAxes(h)
result = all(ishghandle(h)) && ...
length(findobj(h,'type','axes','-depth',0)) == length(h);