errbar documentation

This function plots vertical or horizontal errorbars. Error bars may be symmetic or asymmetric about their data points.



h = errbar(...)


errbar(x,y,E) plots vertical lines of length 2*E centered on x,y. E may be a scalar or a vector matching the size of x.

errbar(x,y,L,U) specifies different lower and upper bounds of error bars. L and U may be mixed vector and scalar.

errbar(...,'horiz') plots error bars horizontally.

errbar(...,LineSpec) specifies line type.

h = errbar(...) returns a handle h of plotted error bars.

Usage note

This function is very similar to Matlab's built-in errorbar function, but the two functions differ in the following ways:

Example 1: Simple vertical error bars

Stealing this example from the documentation for Matlab's built-in errorbar function:

X = 0:pi/10:pi;
Y = sin(X);
E = std(Y);

hold on

errbar(X,Y,E) % <- Here's the errbar function

Example 2: Formatted error bars

Formatting with errbar is as simple as any LineSpec formatting. Each error bar is made of only two endpoints and a line connecting them, so any marker properties will be applied to the ends of the error bars. Here's a simple red error bar with plus signs at its ends:

x = 1:5;
y = sin(x);

hold on


Example 3: Horizontal error bar

Now we'll add horizontal error bars to the plot above. For the lower bound we'll specify a scalar, and for the upper bound some random numbers. Make the error bars thick and black with 'k','linewidth',3 :

xLowerUncertainty = .1;
xUpperUncertainty = (2*rand(size(x))).^2;


Author Info

The errbar function was written by Chad A. Greene of the University of Texas at Austin's Institute for Geophysics, April 2015.