forked from SnPM-toolbox/SnPM-devel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snpm_abline.m
55 lines (43 loc) · 973 Bytes
/
snpm_abline.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function h=snpm_abline(b,a,varargin)
% FORMAT h = snpm_abline(b,a,...)
% Plots y=a*x+b in dotted line on current axis
%
% b - intercept (defaults to 0)
% a - slope (defaults to 1)
% ... - Other line options
%
% Like Splus' abline
%
% FORMAT h = snpm_abline('h',y,...)
% Plots horizontal dotted line at y
%
% FORMAT h = snpm_abline('v',x,...)
% Plots verticle dotted line at x
%
%
%_______________________________________________________________________
% Copyright (C) 2013 The University of Warwick
% Id: snpm_abline.m SnPM13 2013/10/12
% Thomas Nichols
if (nargin==2) && ischar(b)
b = lower(b);
else
if (nargin<1)
b = 0;
end
if (nargin<2)
a = 0;
end
end
XX=get(gca,'Xlim');
YY=get(gca,'Ylim');
if ischar(b) && (b=='h')
g=line(XX,[a a],'LineStyle',':',varargin{:});
elseif ischar(b) && (b=='v')
g=line([a a],YY,'LineStyle',':',varargin{:});
else
g=line(XX,a*XX+b,'LineStyle',':',varargin{:});
end
if (nargout>0)
h=g;
end