使用Mathematica在ErrorListPlot中使用x和y错误的ErrorBarFunction的最小缩放宽度



我有一个同时有x和y错误的数据集。一般来说,y误差约为y值的2%到10%。然而,x误差在x值的0.01%到5%之间变化很大。

我目前正在使用以下方法来绘制我的数据:

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

其中err定义为:

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

取自ErrorBarFunction文档中的示例。然而,由于x方向上的一些小误差,该图根本没有显示框:即,框宽度太小,甚至无法显示一个像素,因此x或y错误都没有显示出来。

我需要写一个函数,有一个最小的错误框宽度

我试着做一些简单的事情,比如:

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]]}]}
   ];

几乎可以工作。但是,由于x轴上的范围可以从+/-5e-3到+/- 10e-3,因此该解决方案仅适用于较小的范围图和较大的ImageSize设置。

所以,我认为我需要使用一些"缩放"的方式来获取坐标,但我不能使用它来获得任何工作。

谁有什么建议?

Tomek

编辑:示例数据:
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]}}

尝试添加EdgeForm到矩形。我想这可以解决矩形的问题根本不显示:

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]}];

相关内容

  • 没有找到相关文章

最新更新