Revision db5f3ef49e53585412627984c44b9db9b188a868 authored by goodalse2019 on 23 February 2021, 20:04:56 UTC, committed by GitHub on 23 February 2021, 20:04:56 UTC
1 parent 788a28f
semshading_ribbonplot.m
function semshading_ribbonplot(Y,a,c,lags)
if exist('a')==0 || isempty(c) % a sets the color
c='r';
end
if exist('lags')==0 || isempty(lags) % lags is the x-axis
lags=1:size(Y,2);
end
Ymean = nanmean(Y,1); % mean over first dimension
Ysem = nanstd(Y,[],1)/sqrt(size(Y,1)); % SEM shading
if exist('a')==0 || isempty(a) % plotting the shading SEM
fill([lags fliplr(lags)],[Ymean+Ysem fliplr(Ymean-Ysem)],c,'linestyle','none');
c='k';
else
fill([lags fliplr(lags)],[Ymean+Ysem fliplr(Ymean-Ysem)],c, 'FaceAlpha', a,'linestyle','none');
end
hold on; plot(lags,Ymean,c,'linewidth',1.5); % plotting the mean line
end
Computing file changes ...