使用举例1:基本使用方法
% Prepare data
y=randn(30,80)5;
x=(1:size(y,2))-40;
yP = sin( linspace(-2pi,2*pi,length(x)) )*20;
y = bsxfun(@plus,y,yP)+60;
% Make the plot
clf
shadedErrorBar(x,y,{@mean,@std});
% Overlay the raw data
hold on
plot(x,y,’.’,‘color’,[0.5,0.5,0.95])
grid on
使用举例2:多条重叠线段绘图
% Prepare data for first line
y=ones(30,1)x;
y=y+0.06y.^2+randn(size(y))*10;
clf
shadedErrorBar(x,y,{@mean,@std},‘lineprops’,’-b’,‘patchSaturation’,0.33)
% Overlay second line
hold on
shadedErrorBar(x,2*y+20,{@mean,@std},‘lineprops’,{’-go’,‘MarkerFaceColor’,‘g’});
%Overlay third line
y=randn(30,80)5; x=(1:size(y,2))-40;
yP = sin( linspace(-2pi,2*pi,length(x)) )*20;
y = bsxfun(@plus,y,yP)+60;
% Make this line non-transparent
shadedErrorBar(x, y, {@mean,@std}, ‘lineprops’, ‘-r’,‘transparent’,false,‘patchSaturation’,0.075)
grid on
使用举例3:改变plot函数绘图特性
% Prepare data
y=randn(30,80)5;
x=(1:size(y,2));
yP = sin( linspace(-2pi,2*pi,length(x)) )*20;
y = bsxfun(@plus,y,yP);
% Plot
clf
s = shadedErrorBar(x, y, {@mean,@std}, ‘lineprops’, ‘-r’);
% Set face and edge properties
set(s.edge,‘LineWidth’,2,‘LineStyle’,’:’)
s.mainLine.LineWidth = 5;
s.patch.FaceColor = [0.5,0.25,0.25];
% Overlay data points post-hoc
hold on
plot(s.mainLine.XData, s.mainLine.YData,‘or’,‘MarkerFaceColor’,‘w’)
grid on
set(gca,‘XTickLabel’,[],‘YTickLabel’,[])
MATLAB源码下载地址:
http://page2.dfpan.com/fs/0lcj82214291067ef42/
更多精彩文章请关注微信号: