|
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) |
|
From: swlab <sw...@co...> - 2005-04-12 17:36:28
|
On Tuesday 12 April 2005 13:11, Edward Holness wrote: > Hi, > > I have a problem with fitting data to a dataset with uncertainties in > gnuplot 4.0 under Linux. > a = 1e-23 > b = 0 1e-23 ? Is it a typo ? > dealing with (xrange [0:0.5], yrange [0:4e-24]). oops, it's not. I'm afraid your values are way too low to have any real significance (computer-wise). AT this level, you're competing with the computer uncertainties. You should multiply your data by a large factor, say, 1e23, and try again. -- Soil & Water Laboratory Dept. of Biological & Environmental Engineering Cornell University Riley-Robb Hall ITHACA, NY 14853 |
|
From: <br...@ph...> - 2005-04-13 11:38:59
|
swlab wrote: > On Tuesday 12 April 2005 13:11, Edward Holness wrote: > I'm afraid your values are way too low to have any real significance > (computer-wise). You're wrong. Absolute scales of values don't cause any problems like that. There is an unfortunate scale dependence on the *parameters* you fit, but neither the scale of x, nor that of y, has much influence on that. |
|
From: <br...@ph...> - 2005-04-13 11:37:37
|
Edward Holness wrote: > 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 This has two errors. First, "using 1:2:3:4" in "fit" means you're doing a 3D fit (f(x,y) fitted to [x,y,z]). Fit, by design, can't have x error bars. Make that "using 1:2:4". Second, start-up values for parameters can't be zero. It even says so somewhere below "help fit", IIRC. |
|
From: Edward H. <ph...@le...> - 2005-04-26 01:04:16
|
Hello,
I am currently writing a piece of software that will write data from
another application and automatically generate a script for gnuplot. I
have run into an obstacle concerning the encoding of file formats.
The errors I get are rather confusing as it appears that gnuplot is
unable to tell line from line. For instance :
set terminal png font '/mnt/win_c/WINNT/Fonts/verdana.ttf' 11
xffffff xclear; reset00 x000000 x000000
^
"work.plot", line 1: invalid color spec, must be xRRGGBB
Which looks nothing like the original script. Copying the contents of a
working script that I have into the file also gives errors. Because of
this I have concluded that my program is writing the script using the
wrong encoding which gnuplot can't read.
Is this consistent with the errors that I'm getting? What form of
encoding should I be using? I'm not entirely sure what I'm using at the
moment, just whatever OpenOffice Basic uses by default.
Does anyone else have experience with such issues when automating
creation of scripts?
Best wishes
Ed
|
|
From: Hans-Bernhard B. <br...@ph...> - 2005-04-26 13:46:13
|
Edward Holness wrote: > I am currently writing a piece of software that will write data from > another application and automatically generate a script for gnuplot. I > have run into an obstacle concerning the encoding of file formats. I somewhat doubt that encoding is the problem. A problem involving the way you send the commands over to gnuplot is more likely. Blocking/buffering errors in communication through pipes have been known to cause this kind of problem. > Which looks nothing like the original script. Copying the contents of a > working script that I have into the file also gives errors. Because of > this I have concluded that my program is writing the script using the > wrong encoding which gnuplot can't read. Then why would a known-correct script instead of the one written by the program also fail? How are you executing the scripts, once they're generated? |
|
From: Edward H. <ph...@le...> - 2005-04-26 14:11:52
|
Hans-Bernhard Broeker wrote: > I somewhat doubt that encoding is the problem. A problem involving the > way you send the commands over to gnuplot is more likely. > Blocking/buffering errors in communication through pipes have been > known to cause this kind of problem. In this case I am not piping. I am writing the script to a flat text file. I now don't think it's encoding either, but something strange with the file. The following can happen: * The file with it's automatically created contents gives an error. * Copying the script to another file means that it works. * Copying a perfectly working script to the file gives an error. It is as if there is something in the file but not the text itself that causes the error. The URL is perfectly OK as moving a working script to the URL and running works fine. > How are you executing the scripts, once they're generated? I'm running my scripts by the shell command: gnuplot [filename]. This works OK on a working script but on this automatically generated script file does not. Thanks for any help |
|
From: Hans-Bernhard B. <br...@ph...> - 2005-04-26 14:18:57
|
Edward Holness wrote: > * The file with it's automatically created contents gives an error. > * Copying the script to another file means that it works. > * Copying a perfectly working script to the file gives an error. In other words, it's apparently the file's name or location, not its content, that causes the problem. So: what is that name and location, actually? On what platform? > It is as if there is something in the file but not the text itself that > causes the error. The URL is perfectly OK as moving a working script to > the URL and running works fine. URLs don't exist in gnuplot's view of the world. |
|
From: Edward H. <ph...@le...> - 2005-04-26 14:39:36
|
Hans-Bernhard Broeker wrote: > In other words, it's apparently the file's name or location, not its > content, that causes the problem. So: what is that name and location, > actually? On what platform? I'm running Mandrake 10.1 with kernel 2.6. I think I've found some idea of what the cause is. If I open the script for editing and at the head of the file press backspace a couple of times the file works. There is some kind of non printing invisible character at the head of the file. Most odd. :-\ I think I can now work this out in my program, something wrong I'm doing there! Thank you again. |