You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
997 B
Matlab

function h=plot_confidence(x,y,colour,style,type,range)
if nargin<3, colour=[0 0.4470 0.7410]; end
if nargin<4, style='-'; end
if nargin<5, type='fill'; end
if nargin<6, range='minmax'; end
if iscell(y)
for i=1:length(y)
meany(i)=mean(y{i});
if isempty(y{i})
miny(i)=NaN;
maxy(i)=NaN;
stdy(i)=NaN;
else
miny(i)=min(y{i});
maxy(i)=max(y{i});
stdy(i)=std(y{i});
end
end
else
meany=mean(y,1);
miny=min(y,[],1);
maxy=max(y,[],1);
stdy=std(y);
end
switch range
case 'minmax'
L=miny;
U=maxy;
case 'std'
L=meany-stdy;
U=meany+stdy;
end
switch type
case 'fill'
X=[x,fliplr(x)];
Y=[L,fliplr(U)];
fill(X,Y,colour,'EdgeColor',colour,'FaceAlpha',0.4,'EdgeAlpha',0);
hold on;
h=plot(x,meany,style,'Color',colour,'LineWidth',2);
case 'bars'
h=errorbar(x,meany,meany-L,meany-U,style,'Color',colour,'LineWidth',2);
case 'mean'
h=plot(x,meany,style,'Color',colour,'LineWidth',2);
end