| Description |
Creates a continuous shaded error region rather than discrete bars. Error region can either be specified explicitly or calculated on the fly based upon function handles. Handles of the plot objects are returned in a convenient structure.
function H=shadedErrorBar(x,y,errBar,lineProps,transparent)
Purpose
Makes a 2-d line plot with a pretty shaded error bar made
using patch. Error bar color is chosen automatically.
Inputs
x - vector of x values
y - vector of y values or a matrix of n observations by m cases
where m has length(x);
errBar - if a vector we draw symmetric errorbars. If it has a
size of [2,length(x)] then we draw asymmetric error bars
with row 1 being the upper bar and row 2 being the lower
bar. ** alternatively ** errBar can be a cellArray of
two function handles. The first defines which statistic
the line should be and the second defines the error
bar.
lineProps - [optional,'-k' by default] defines the properties of
the data line. e.g.:
'or-', or {'-or','markerfacecolor',[1,0.2,0.2]}
transparent - [optional, 0 by default] if ==1 the shaded error
bar is made transparent, which forces the renderer
to be openGl. This means that saved .eps files
won't look so good because they'll be rasters not
vectors.
Outputs
H - a structure of handles to the generated plot objects.
Examples
y=randn(30,80); x=1:size(y,2);
shadedErrorBar(x,mean(y,1),std(y),'g');
shadedErrorBar(x,y,{@median,@std},{'r-o','markerfacecolor','r'});
Overlay two transparent lines
y=randn(30,80)*10; x=(1:size(y,2))-40;
shadedErrorBar(x,y,{@mean,@std},'-r',1);
hold on
y=ones(30,1)*x; y=y+0.06*y.^2+randn(size(y))*10;
shadedErrorBar(x,y,{@mean,@std},'-b',1);
Rob Campbell - November 2009
|