function errorbars(labels,y,e,options) %ERRORBARS ? % % INPUTS: % % OUTPUTS: % % Brain & Computation Lab CS Dept. UNM % http://www-bcl.cs.unm.edu http://www.cs.unm.edu % % $RCSfile: errorbars.m,v $ % $Source: /home/cvs/yoh/progr/matlab/gen_ica_func/errorbars.m,v $ % % Created: Wed Aug 14 18:54:13 2002 % Commited: $Date: 2006/03/13 17:40:39 $ % Revision: $Revision: 1.5 $ %clf; cla; legend off; N = length(y); x=1:N; NL=0; if (exist('options','var')) NL=length(options.lines); if (NL>0) rr = options.lines; nlz = find(rr>0); rr = abs(rr); yl=y(rr); y(rr)=[]; el=e(rr); e(rr)=[]; labelsl =labels(rr,:); labels(rr,:)=[]; N = N - NL; x = 1:N; end if (options.sorted) [v in] = sort(y); in = in(N:-1:1); y = y(in); labels(:,:) = labels(in,:); e = e(in); end if (options.nolegend) nolegend = 1; else nolegend = 0; end end hold on; hb=bar(x,diag(y),'stacked');colormap('gray'); set(hb,'LineWidth',1.5); set(gca,'FontSize',12); if (exist('options','var')) & (~nolegend) legend(hb,labels); end he=errorbar(x,y,e,'b'); set(he(1),'linewidth',2); %set(he(2),'visible','off'); for i=1:length(x) hh= text(x(i)-.4,y(i),num2str(y(i),4),'VerticalAlignment','bottom',... 'HorizontalAlignment','left','FontWeight','bold', 'FontSize',8);%, 'FontName','fixed'); set(hh,'EraseMode','xor') % text(x(i),y(i)+max(e(i),0.15),[num2str(y(i),4), '\newline \delta = ' num2str(e(i),3)],'VerticalAlignment','bottom',... % 'HorizontalAlignment','center', 'FontSize', 8) end set(gca,'XTick',x); set(gca,'XTickLabel',[]); % labels if (NL) for ik=nlz Xs = get(gca,'XLim') lh = line(Xs,[yl(ik),yl(ik)]); text(Xs(2),yl(ik),trim_spaces(labelsl(ik,:)),'VerticalAlignment','bottom',... 'HorizontalAlignment','Right'); end end hold off; function s = trim_spaces(s) while ((length(s)>0) & (s(end)==' ')) s(end)=[]; end