Using Error Bars in Mathematica

Gary L. Gray
Assistant Professor
Engineering Science and Mechanics
The Pennsylvania State University
227 Hammond Building
University Park, PA 16802
gray@engr.psu.edu

You must use the MultipleListPlot command to use error bars. To use this command, you must first load the package that defines it.

<< Graphics`MultipleListPlot`

Now create a list of four points that have some random error on them, put these points in a list and add the error bars. Notice that the general syntax is:

{{x1, y1, ErrorBar[xerr1, yerr1]}, {x2, y2, 
        ErrorBar[xerr2, yerr2]},  ... , {xn, yn, 
        ErrorBar[xerrn, yerrn]}}

I now use the Table command to generate some x and y values along with a little "noise" (created by adding a small random number to both the x and y values) based on the sine curve. Notice that I add the error bars as I generate the numbers and that I use the same amount of error on each data point. When you do this, you will generally enter your data and error bar info one point at a time.

list1 = 
      Table[{{x + Random[Real, {0, 0.1}], 
            Sin[2 π x] + Random[Real, {0, 0.1}]}, 
          ErrorBar[0.1, 0.2]}, {x, 0, 1, 0.33}]

Using the "Help Browser..." under the "Help" menu and searching for "MultipleListPlot" will allow you to see all of the other available options. Now plot it:

plot1 = MultipleListPlot[list1]

Plot an exact sine curve.

plot2 = Plot[Sin[2 π x], {x, 0, 1}]

Now combine both curves to see how our data compares.

Show[plot1, plot2]