3
$\begingroup$
   ErrorListPlot[{{{0.05/0.17, 0.08/0.17}, 
   ErrorBar[0.01/0.17]}, {{0.05/0.18, 0.08/0.18}, 
   ErrorBar[0.01/0.18]}, {{0.05/0.19, 0.07/0.19}, 
   ErrorBar[0.01/0.19]}, {{0.05/0.2, 0.07/0.2}, 
   ErrorBar[0.01/0.2]}, {{0.05/0.21, 0.07/0.21}, 
   ErrorBar[0.01/0.21]}, {{0.05/0.22, 0.07/0.22}, 
   ErrorBar[0.01/0.22]}, {{0.05/0.23, 0.07/0.23}, 
   ErrorBar[0.01/0.23]}, {{0.05/0.24, 0.07/0.24}, 
   ErrorBar[0.01/0.24]}, {{0.05/0.25, 0.06/0.25}, 
   ErrorBar[0.01/0.25]}, {{0.05/0.26, 0.06/0.26}, 
   ErrorBar[0.01/0.26]}, {{0.05/0.27, 0.06/0.27}, 
   ErrorBar[0.01/0.27]}, {{0.05/0.28, 0.06/0.28}, 
   ErrorBar[0.01/0.28]}, {{0.05/0.29, 0.05/0.29}, 
   ErrorBar[0.01/0.29]}, {{0.05/0.3, 0.05/0.3}, 
   ErrorBar[0.01/0.3]}, {{0.05/0.31, 0.05/0.31}, 
   ErrorBar[0.01/0.31]}, {{0.05/0.32, 0.04/0.32}, 
   ErrorBar[0.01/0.32]}, {{0.05/0.33, 0.04/0.33}, 
   ErrorBar[0.01/0.33]}, {{0.05/0.34, 0.03/0.34}, 
   ErrorBar[0.01/0.34]}, {{0.05/0.35, 0.03/0.35}, 
   ErrorBar[0.01/0.35]}, {{0.05/0.36, 0.02/0.36}, 
   ErrorBar[0.01/0.36]}, {{0.05/0.37, 0.02/0.37}, 
   ErrorBar[0.01/0.37]}, {{0.05/0.16, 0.08/0.16}, 
   ErrorBar[0.01/0.16]}, {{0.05/0.15, 0.08/0.15}, 
   ErrorBar[0.01/0.15]}, {{0.05/0.14, 0.08/0.14}, 
   ErrorBar[0.01/0.14]}, {{0.05/0.13, 0.09/0.13}, 
   ErrorBar[0.01/0.13]}, {{0.05/0.135, 0.08/0.135}, 
   ErrorBar[0.01/0.135]}, {{0.05/0.145, 0.08/0.145}, 
   ErrorBar[0.01/0.145]}, {{0.05/0.155, 0.08/0.155}, 
   ErrorBar[0.01/0.155]}, {{0.05/0.165, 0.08/0.165}, 
   ErrorBar[0.01/0.165]}, {{0.05/0.175, 0.08/0.175}, 
   ErrorBar[0.01/0.175]}, {{0.05/0.185, 0.08/0.185}, 
   ErrorBar[0.01/0.185]}, {{0.05/0.195, 0.07/0.195}, 
   ErrorBar[0.01/0.195]}, {{0.05/0.205, 0.07/0.205}, 
   ErrorBar[0.01/0.205]}, {{0.05/0.215, 0.07/0.215}, 
   ErrorBar[0.01/0.215]}, {{0.05/0.375, 0.00/0.375}, 
   ErrorBar[0.01/0.375]}}]

Plot of above data

I have above data with error bars, and I try to connect those dots to make a smooth line. I have no idea what fit model should I use and the fitting doesn't have to be linear and can be wavy. The fitting is something looks like this: enter image description here

How can I do this? Thx!

$\endgroup$
7
  • $\begingroup$ What might be causing the "jumps" in the data? The data is pretty linear for a few points in a row and then there's a jump. And the jumps take longer to occur with increasing values of the horizontal variable. $\endgroup$
    – JimB
    Aug 21, 2016 at 5:55
  • $\begingroup$ I am guessing the "jumps" in the data is due to the limiting digit of the data, for example, those 0.08 in the data can be 0.081, 0.082 etc, but it is really hard to get the data to the accuracy of 0.001, and that is why I am including the error bar. $\endgroup$
    – lol
    Aug 21, 2016 at 5:59
  • $\begingroup$ The size of the error bars between the horizontal values of .275 to 0.375 are much too large for the errors about the line to be independent. There must be some serial correlation. Are these successive measurements on a single experimental unit? I ask because besides the "shape" of the curve, approximating the error structure is important, too. $\endgroup$
    – JimB
    Aug 21, 2016 at 6:05
  • $\begingroup$ Well, these error bars are large because if you look at my above data, .275 to .375 correspond to 0.05/0.18 to 0.05/0.13. Their corresponding error bar magnitude is 0.01/0.18 to 0.01/0.13 (where the 0.01 is fixed). Since 0.13 to 0.18 are small numbers, the error bars should be large. $\endgroup$
    – lol
    Aug 21, 2016 at 6:14
  • $\begingroup$ We speak a different language and I'm not communicating well. It is obvious to you that the "error bar magnitude" becomes larger with increasing horizontal values. Is that one standard deviation from some probability distribution which increases linearly with larger horizontal values? A plot of the "error bar magnitudes" vs. the horizontal variable is near perfectly linear. $\endgroup$
    – JimB
    Aug 21, 2016 at 6:26

2 Answers 2

2
$\begingroup$

Copy and paste the list inside the ErrorListPlot

Then you can extract the x and y points of the list via:

data = {
  {{0.05/0.17, 0.08/0.17}, ErrorBar[0.01/0.17]},
  {{0.05/0.18, 0.08/0.18}, ErrorBar[0.01/0.18]},
  {{0.05/0.19, 0.07/0.19}, ErrorBar[0.01/0.19]},
   .
   .
   .
{{0.05/0.375, 0.00/0.375}, ErrorBar[0.01/0.375]}
  }[[All, 1]]

A reasonable fit to the data is a third degree polynomial

sol = FindFit[data, a + b x + c x^2 + d x^3,
         {{a, -1}, {b, 10}, {c, -30}, {d, 35}}, x]

(* {a -> -0.878902, b -> 10.1701, c -> -29.4332, d -> 34.9043} *)

Check the fit

Show[
 ListPlot[data, PlotStyle -> Black],
 Plot[a + b x + c x^2 + d x^3 /. sol,
  {x, 0.1, 0.4},
   PlotStyle -> Red
  ],
 PlotRange -> {{0.1, 0.4}, {0, 0.8}},
 AxesOrigin -> {0.1, 0}
 ]

Mathematica graphics

$\endgroup$
1
$\begingroup$

Just to illustrate 'getting under the hood' of graphics and to illustrate some other features:

Setup:

Needs["ErrorBarPlots`"]
eblp = {{{0.05/0.17, 0.08/0.17}, 
    ErrorBar[0.01/0.17]}, {{0.05/0.18, 0.08/0.18}, 
    ErrorBar[0.01/0.18]}, {{0.05/0.19, 0.07/0.19}, 
    ErrorBar[0.01/0.19]}, {{0.05/0.2, 0.07/0.2}, 
    ErrorBar[0.01/0.2]}, {{0.05/0.21, 0.07/0.21}, 
    ErrorBar[0.01/0.21]}, {{0.05/0.22, 0.07/0.22}, 
    ErrorBar[0.01/0.22]}, {{0.05/0.23, 0.07/0.23}, 
    ErrorBar[0.01/0.23]}, {{0.05/0.24, 0.07/0.24}, 
    ErrorBar[0.01/0.24]}, {{0.05/0.25, 0.06/0.25}, 
    ErrorBar[0.01/0.25]}, {{0.05/0.26, 0.06/0.26}, 
    ErrorBar[0.01/0.26]}, {{0.05/0.27, 0.06/0.27}, 
    ErrorBar[0.01/0.27]}, {{0.05/0.28, 0.06/0.28}, 
    ErrorBar[0.01/0.28]}, {{0.05/0.29, 0.05/0.29}, 
    ErrorBar[0.01/0.29]}, {{0.05/0.3, 0.05/0.3}, 
    ErrorBar[0.01/0.3]}, {{0.05/0.31, 0.05/0.31}, 
    ErrorBar[0.01/0.31]}, {{0.05/0.32, 0.04/0.32}, 
    ErrorBar[0.01/0.32]}, {{0.05/0.33, 0.04/0.33}, 
    ErrorBar[0.01/0.33]}, {{0.05/0.34, 0.03/0.34}, 
    ErrorBar[0.01/0.34]}, {{0.05/0.35, 0.03/0.35}, 
    ErrorBar[0.01/0.35]}, {{0.05/0.36, 0.02/0.36}, 
    ErrorBar[0.01/0.36]}, {{0.05/0.37, 0.02/0.37}, 
    ErrorBar[0.01/0.37]}, {{0.05/0.16, 0.08/0.16}, 
    ErrorBar[0.01/0.16]}, {{0.05/0.15, 0.08/0.15}, 
    ErrorBar[0.01/0.15]}, {{0.05/0.14, 0.08/0.14}, 
    ErrorBar[0.01/0.14]}, {{0.05/0.13, 0.09/0.13}, 
    ErrorBar[0.01/0.13]}, {{0.05/0.135, 0.08/0.135}, 
    ErrorBar[0.01/0.135]}, {{0.05/0.145, 0.08/0.145}, 
    ErrorBar[0.01/0.145]}, {{0.05/0.155, 0.08/0.155}, 
    ErrorBar[0.01/0.155]}, {{0.05/0.165, 0.08/0.165}, 
    ErrorBar[0.01/0.165]}, {{0.05/0.175, 0.08/0.175}, 
    ErrorBar[0.01/0.175]}, {{0.05/0.185, 0.08/0.185}, 
    ErrorBar[0.01/0.185]}, {{0.05/0.195, 0.07/0.195}, 
    ErrorBar[0.01/0.195]}, {{0.05/0.205, 0.07/0.205}, 
    ErrorBar[0.01/0.205]}, {{0.05/0.215, 0.07/0.215}, 
    ErrorBar[0.01/0.215]}, {{0.05/0.375, 0.00/0.375}, 
    ErrorBar[0.01/0.375]}};

Producing plot with error bars, fitted curve (LinearModelFit but could also do as per Jack LaVigne or whatever model relevant to data) and producing legend.

da = Normal@LinearModelFit[eblp[[All, 1]], {1, x, x^2, x^3}, x];
Framed@Legended[
  Show[ErrorListPlot[eblp] /. 
      Point[x__] :> {Red, PointSize[0.02], Point[x]}, 
     Plot[da, {x, ##}, PlotStyle -> {Black, Dashed}]] & @@ 
   MinMax[eblp[[All, 1, 1]]], 
  Placed[Column[{PointLegend[{Red}, {"data"}], 
     LineLegend[{Directive[Black, Dashed]}, {da}]}], Below]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.