-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotShadedSD.m
More file actions
54 lines (44 loc) · 1.21 KB
/
plotShadedSD.m
File metadata and controls
54 lines (44 loc) · 1.21 KB
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
function ah = plotShadedSD(varargin)
% plotShadedSD(timeframe,Data,SD,[colors_cellarray]) or plotShadedSD(ah,timeframe,Data,SD,[colors_cellarray])
col_str = {};
if ishandle(varargin{1})
ah = varargin{1};
timeframe = varargin{2};
Data = varargin{3};
SD = varargin{4};
if nargin>4
col_str = varargin{5};
end
else
timeframe = varargin{1};
Data = varargin{2};
SD = varargin{3};
if nargin>3
col_str = varargin{4};
end
figure;
ah = gca;
end
numpts = length(timeframe);
xIdx = [1:numpts numpts:-1:1];
xarea = timeframe(xIdx);
% xarea = xIdx;
hold on;
if isempty(col_str)
plot(ah,timeframe,Data);
else
for i = 1:size(Data,2)
plot(ah,timeframe,Data(:,i),col_str{i});
end
end
pretty_fig;
lines = flipud(get(ah,'Children'));
for i = 1:size(Data,2)
ytop = Data(:,i) + SD(:,i);
ybot = Data(:,i) - SD(:,i);
yarea = [ytop; ybot(end:-1:1)];
patch(xarea,yarea,lines(i).Color,'LineStyle','none','FaceAlpha',0.3);
% area(xarea,yarea,'Facecolor',lines(i).Color,'LineStyle','none','FaceAlpha',0.3);
end
% flip order of lines
%set(gca,'children',flipud(get(gca,'children')));