-
Notifications
You must be signed in to change notification settings - Fork 0
/
myeb.m
107 lines (97 loc) · 2.78 KB
/
myeb.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function myeb(Y,varargin);
%
% myeb(Y,varargin);
%
% This function makes nice coloured, shaded error bars. Exactly what
% it does depends on Y, and on whether you give it one or two inputs.
%
% If you only pass it Y, and no other arguments, it assuemd you're
% giving it raw data.
%
% myeb(Raw_Data)
%
% .) if Y is 2D array, it will then plot mean(Y) with errorbars given
% by std(Y). In this case there is only one mean vector with its
% errorbars.
%
% .) if Y is 3D array, it will plot size(Y,3) lines with the
% associated errorbars. Line k will be mean(Y(:,:,k)) with errorbars
% given by std(Y(:,:,k))
%
% If you pass it 2 arguments, each has to be at most 2D.
%
% myeb(mu,std)
%
% .) if mu and std are 1D, it just plots one line given by mu with a
% shaded region given by std.
%
% .) if mu and std are 2D, it will plot size(Y,2) lines in the
% standard sequence of colours; each line mu(:,k) will have a shaded
% region in the same colour, but less saturated given by std(:,k)
%
%
% Quentin Huys, 2007
% Center for Theoretical Neuroscience, Columbia University
% Email: qhuys [at] n e u r o theory [dot] columbia.edu
% (just get rid of the spaces, replace [at] with @ and [dot] with .)
col=[0 0 1; 0 .5 0; 1 0 0; 0 1 1; 1 0 1; 1 .5 0; 1 .5 1];
ccol=col+.8; ccol(ccol>1)=1;
if length(varargin)==0;
if length(size(Y))==2
m=mean(Y);
s=std(Y);
ind1=1:length(m);
ind2=ind1(end:-1:1);
hold on; h=fill([ind1 ind2],[m-s m(ind2)+s(ind2)],.6*ones(1,3));
set(h,'edgecolor',.6*ones(1,3))
plot(ind1,m,'linewidth',2)
hold off
elseif length(size(Y))>2
cla; hold on;
ind1=1:size(Y,2);
ind2=ind1(end:-1:1);
if size(Y,3)>8; col=jet(size(Y,3));ccol=col+.8; ccol(ccol>1)=1;end
for k=1:size(Y,3)
m=mean(Y(:,:,k));
s=std(Y(:,:,k));
h=fill([ind1 ind2],[m-s m(ind2)+s(ind2)],ccol(k,:));
set(h,'edgecolor',ccol(k,:))
end
for k=1:size(Y,3)
m=mean(Y(:,:,k));
s=std(Y(:,:,k));
plot(ind1,m,'linewidth',2,'color',col(k,:))
end
hold off
end
elseif length(varargin)==1;
m=Y;
s=varargin{1};
if length(size(Y))>2; error;
elseif min(size(Y))==1;
if size(m,1)>1; m=m';s=s';end
ind1=1:length(m);
ind2=ind1(end:-1:1);
hold on; h=fill([ind1 ind2],[m-s m(ind2)+s(ind2)],.6*ones(1,3));
set(h,'edgecolor',.6*ones(1,3))
plot(ind1,m,'linewidth',2)
hold off
else
ind1=(1:size(Y,1));
ind2=ind1(end:-1:1);
cla; hold on;
if size(Y,2)>8; col=jet(size(Y,2));ccol=col+.8; ccol(ccol>1)=1;end
for k=1:size(Y,2)
mm=m(:,k)';
ss=s(:,k)';
h=fill([ind1 ind2],[mm-ss mm(ind2)+ss(ind2)],ccol(k,:));
set(h,'edgecolor',ccol(k,:))
end
for k=1:size(Y,2);
mm=m(:,k)';
ss=s(:,k)';
plot(ind1,mm,'linewidth',2,'color',col(k,:))
end
hold off
end
end