-
Notifications
You must be signed in to change notification settings - Fork 5
/
addpstars.m
56 lines (52 loc) · 1.54 KB
/
addpstars.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
56
% plot colored symbols (by default asterisks) into the axis. This is useful
% for illustrating significant effects in overlapping plots (e.g. line
% graphs).
%
% INPUTS:
% ax - default gca
% xs - [1 by nx] x positions (we ignore NaN entries)
% pmat - [condition by nx] matrix of p stats
% cmat - [condition by rgb] matrix of colours
%
% NAMED INPUTS:
% ypos - [condition by 1] position in y. We use max(ylim) if undefined.
% sigthresh - default .05
% sigsym - default '*'
% verticalalignment - default 'bottom'
% horizontalalignment - default 'center'
%
% t = addpstars(ax,xs,pmat,cmat,varargin)
function t = addpstars(ax,xs,pmat,cmat,varargin)
getArgs(varargin,{'sigthresh',.05,'sigsym','*','fontsize',10,...
'ypos',max(get(ax,'ylim')),'verticalalignment','bottom',...
'horizontalalignment','center'});
t = NaN;
if all(isnan(pmat(:)) | pmat(:) > sigthresh)
% nothing to do here
return;
end
xs = xs(~isnan(xs));
nx = size(pmat,2);
np = size(pmat,1);
if ieNotDefined('cmat')
% assume you want all black
cmat = zeros(np,3);
end
if numel(ypos)==1
ypos = repmat(ypos,[1 nx]);
end
pstr = repmat({''},[1 nx]);
for x = 1:size(pmat,2)
pv = pmat(:,x);
for y = 1:np
if pmat(y,x)<sigthresh
pstr{x} = [pstr{x} sprintf('{\\color[rgb]{%f %f %f}%s}',cmat(y,1),...
cmat(y,2),cmat(y,3),sigsym)];
end
end
end
t = text(double(xs(~isnan(ypos))),double(ypos(~isnan(ypos))),pstr,...
'verticalalignment',verticalalignment,...
'horizontalalignment',horizontalalignment,...
'fontsize',fontsize,...
'fontweight','bold','parent',ax);