|
From: Edward H. <ph...@le...> - 2005-04-12 17:11:58
|
Hi, I have a problem with fitting data to a dataset with uncertainties in gnuplot 4.0 under Linux. The data file I am using is of the form: x y xerror yerror I can plot this data complete with error bars with the line: plot "data.txt" using 1:2:3:4 with xyerrorbars This works perfectly, what doesn't work is trying to fit a straight line too it for which I am trying: f(x) = a*x + b a = 1e-23 b = 0 fit f(x) 'data.txt' using 1:2:3:4 via a, b For some reason the line I get (which is meant to be calculated from uncertainties) is far from where it should be. It runs at y = 0.00635613x + 0.0041886, which is off the scale of the points that I'm dealing with (xrange [0:0.5], yrange [0:4e-24]). Any ideas what is going wrong? I've tried numerous 'using' arguments to no avail. Here is my entire script: clear; reset f(x) = a*x + b a = 1e-23 b = 0 fit f(x) 'data.txt' using 1:2:3:4 via a, b set terminal png font "/mnt/win_c/WINNT/Fonts/verdana.ttf" 11 xffffff x000000 x000000 x000000 x000000 set output "mb.png" set title "Magnetic field strength vs dE" set xlabel "B (T)" set ylabel "dE (J)" set key off plot "data.txt" using 1:2:3:4 with xyerrorbars set xrange [0:0.5]; replot set yrange [0:4e-24]; replot replot f(x) |