3
votes

I have a data set which has both x and y errors. Generically, the y errors are on the order of 2% to 10% of the y value. The x errors, however, vary greatly from .01% to 5% of the x values.

I am currently using the following to plot my data:

ErrorListPlot[ errorPlotData[#], 
    ImageSize -> 800, 
    PlotRange -> All, 
    ErrorBarFunction -> err]

Where err is defined as:

err[coords_, errs_] := {
    Opacity[0.2], 
    Rectangle[
        coords + {errs[[1, 1]], errs[[2, 1]]}, 
        coords + {errs[[1, 2]], errs[[2, 2]]}
    ]
}

This is taken from the example in the docs on ErrorBarFunction. However, due to some of the small errors in the x direction, the plot does not show the box at all: i.e., the box width is too small to even display a pixel, and so neither the x or y errors show up.

I need to write a function that has a minimum error box width.

I tried to do something simple like:

err[coords_, errs_] := Module[{x0, x1, y0, y1},
   x0 = errs[[1, 1]];
   x1 = errs[[1, 2]];
   If[(x1 - x0) < 10^-6, x0 = 10^-6; x1 = -10^-6];
   {Opacity[0.2], 
    Rectangle[coords + {x0, errs[[2, 1]]}, 
     coords + {x1, errs[[2, 2]]}]}
   ];

And that almost works. However, since the range on the x axis can be range from +/-5e-3 to +/- 10e-3, the solution only works for the smaller range plots and larger ImageSize settings.

So, I think I need to use some "Scaled" way of getting the coordinates, but I can't get anything to work using that.

Anyone have any suggestions?

Tomek

Edit: sample data:

In[1069]:= errorPlotData["70"][[1 ;; 20, All]]

Out[1069]= {{{0.0006131, 7314.3}, 
  ErrorBar[1.9084*10^-7, 309.11]}, {{0.00060638, 7339.9}, 
  ErrorBar[2.3891*10^-7, 310.03]}, {{0.00060042, 7401.7}, 
  ErrorBar[4.9478*10^-8, 331.15]}, {{0.00059433, 7340.3}, 
  ErrorBar[6.3614*10^-8, 348.5]}, {{0.00058777, 7351.5}, 
  ErrorBar[1.9791*10^-8, 323.53]}, {{0.00058167, 7349.3}, 
  ErrorBar[6.9976*10^-8, 335.46]}, {{0.00057494, 7405.8}, 
  ErrorBar[3.6967*10^-7, 319.49]}, {{0.00056835, 7341.}, 
  ErrorBar[3.4705*10^-7, 364.98]}, {{0.00056223, 7392.4}, 
  ErrorBar[1.7317*10^-7, 336.12]}, {{0.00055588, 7398.}, 
  ErrorBar[1.2794*10^-7, 353.29]}, {{0.00054985, 7344.3}, 
  ErrorBar[3.5341*10^-8, 350.58]}, {{0.0005436, 7363.3}, 
  ErrorBar[6.8562*10^-8, 371.04]}, {{0.00053714, 7426.6}, 
  ErrorBar[3.0959*10^-7, 353.86]}, {{0.00053092, 7409.1}, 
  ErrorBar[4.1915*10^-7, 366.35]}, {{0.00052528, 7385.}, 
  ErrorBar[1.3006*10^-7, 361.69]}, {{0.00051836, 7464.1}, 
  ErrorBar[1.2016*10^-7, 354.99]}, {{0.0005129, 7454.5}, 
  ErrorBar[8.2698*10^-8, 336.79]}, {{0.00050656, 7404.3}, 
  ErrorBar[2.0569*10^-7, 345.19]}, {{0.00050042, 7432.7}, 
  ErrorBar[7.0682*10^-9, 327.78]}, {{0.00049395, 7475.4}, 
  ErrorBar[1.138*10^-7, 343.1]}}
1
What is errorPlotData[#] here? Do you have a small sample data set that I could test with? - Arnoud Buzing
@ArnoudBuzing, good catch, didn't notice that while I was editing it. - rcollyer
@ArnoudBuzing sorry about that. Will that be enough data for you? (I have 201 points total. - tkott

1 Answers

4
votes

Try adding EdgeForm to the Rectangle. I think this may solve the problem with the rectangle not showing at all:

err[coords_, errs_] := Module[{x0, x1, y0, y1},
 x0 = errs[[1, 1]];
 x1 = errs[[1, 2]];
 {Pink, EdgeForm[{Pink}], Rectangle[coords + {x0, errs[[2, 1]]}, 
 coords + {x1, errs[[2, 2]]}], Blue, Point[coords]}];