Plot data with error bars on both x and y axes
ERRORBARXY is a function to generate errorbars on both x and y axes with specified errors modified from codes written by Nils Sjöberg (http://www.mathworks.com/matlabcentral/fileexchange/5444-xyerrorbar)
errorbarxy(x, y, lx, ux, ly, uy) plots the data with errorbars on both x and y axes with error bars [x-lx, x+ux] and [y-ly, y+uy]. If there is no error on one axis, set corresponding lower and upper bounds to [].
errorbarxy(x, y, errx, erry) plots the data with errorbars on both x and y axes with error bars [x-errx, x+errx] and [y-erry, y+erry]. If there is no error on one axis, set corresponding errors to [].
errorbarxy(..., COLOR) plots data as well as errorbars in specified colors. COLOR is a cell array of 3 element, {cData, cEBx, cEBy}, where cData specifies the color of main plot, cEBx specifies the color of errorbars along x axis and cEBy specifies the color of errorbars along y axis.
errorbarxy(AX,...) plots into AX instead of GCA.
H = errorbar(...) returns a vector of errorbarseries handles in H, within which the first element is the handle to the main data plot and the remaining elements are handles to the rest errorbars.
For example
x = 1:10;
xe = 0.5*ones(size(x));
y = sin(x);
ye = std(y)*ones(size(x));
errorbarxy(x,y,xe,ye,{'k', 'b', 'r'});
draws symmetric error bars on both x and y axes.
NOTE: errorbars are excluded from legend display. If you need to include errorbars in legend display, do the followings:
H=errorbarxy(...);
arrayfun(@(d) set(get(get(d,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on'), H(2:end)); % include errorbars
hEB=hggroup;
set(H(2:end),'Parent',hEB);
set(get(get(hEB,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on'); % include errorbars in legend as a group.
legend('Main plot', 'Error bars');
Developed under Matlab version 7.10.0.499 (R2010a)
Created by Qi An
anqi2000@gmail.com