123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- function plpc=plotperc(xaxis, yvalues, percvals, colorvs, alpha)
- if nargin<5
- alpha=.1;
- end
- if nargin>=4 && ischar(colorvs) && contains('kbgcrmyw',colorvs(1))
- color=rem(floor((strfind('kbgcrmyw',colorvs(1))-1)*[.25 .5 1]),2);
- elseif nargin>=4 && isa(colorvs,'double')
- color=colorvs(1:3);
- else
- color=[0 0 0];
- end
- if nargin<3
- percvals=[05 95];
- end
- if ~any(size(percvals)==2)
- error('percvals input is not correct');
- end
- if size(percvals,1)==2 && size(percvals,2)~=2
- percvals=percvals';
- end
- % force xaxis and yvalues to have same number of rows (not columns)
- if size(yvalues,2)~=length(xaxis)
- yvalues=yvalues';
- end
- if size(yvalues,2)~=length(xaxis)
- error('xaxis and yvalues do not match in size');
- end
- for vv=1:size(percvals,1)
- perc2=prctile(yvalues,percvals(vv,2),1);
- if(percvals(1)==-inf)
- perc1=repmat(min(get(gca,'YLim')),1,length(xaxis));
- else
- perc1=prctile(yvalues,percvals(vv,1),1);
- end
-
- %perc1(perc1<1e-50)=nan; % hardcoded fix for singularities
- %perc2(perc2<1e-50)=nan; % hardcoded fix for singularities
-
- pp=[perc1 perc2(end:-1:1)]';
- xp=[xaxis xaxis(end:-1:1)]';
-
- hold on;
- %fill([xaxis xaxis(end:-1:1)]',[perc1 perc2(end:-1:1)]',color,'facealpha',alpha,'linestyle','none'); hold on;
- plpc(vv).fill=fill(xp(isfinite(pp)),pp(isfinite(pp)),color,'facealpha',alpha,'linestyle','none'); hold on;
- end
- end
|