Previous iTool User's Guide: Working with Plots Next

Adding Error Bars

Error bars are used to show uncertainty in data values. These uncertainties may be caused by measurement errors or instrument noise, and are usually specified in terms of standard deviations away from the data value.

For example, to create a 2D plot with asymmetric error bars on the X and Y axes, follow these steps:

  1. To set asymmetric error bars for X and Y with X bars initially hidden, enter:
  2. err = FLTARR(2,10)  
    err[0, *] = FINDGEN(10)/10.  
    err[1, *] = FLTARR(10) + 0.5  
    

     

  3. Plot the error bars in the iPlot window:
  4. iPlot, FINDGEN(10), COLOR = [255, 0, 255],$  
       ERRORBAR_COLOR = [255, 0, 0], $  
       ERRORBAR_CAPSIZE = 0.25, X_ERRORBARS = 0, $  
       XERROR = err, YERROR = err  
    

     

    Figure 13-8: 2D Plot with Error Bars

    Figure 13-8: 2D Plot with Error Bars

Also, to create a 3D plot with asymmetric error bars on the X, Y and Z axes:

  1. To set asymmetric error bars for a 3D plot, enter:
  2. nVerts = 30  
    x = FINDGEN(nVerts)/10.  
    y = (SIN(x*2) + 1.)*25.  
    z = x  
    err = FLTARR(2, nVerts)  
    err[0, *] = RANDOMU(seed, nVerts)  
    err[1, *] = RANDOMU(seed, nVerts)  
    

     

  3. Plot the error bars in the iPlot window with 3D plot and name the plot "3D Plot with Error Bars":
  4. iPlot, x, y, z, COLOR = [0, 0, 255], $  
       THICK = 2, ERRORBAR_COLOR = [255, 0, 0], $  
       XERROR = err/2., YERROR = err*5., ZERROR = err, $  
       NAME = '3D Plot with Error Bars'  
    

     

    Figure 13-9: 3D Plot with Error Bars and Name

    Figure 13-9: 3D Plot with Error Bars and Name

For more information on error-bar properties, see Plot.

  IDL Online Help (March 01, 2006)