Is gnuplot influenced by the terminal?

I have a gnuplot script file to measure measurement data using this structure:

set terminal png

...some format templates...

f(x) = a + b*x + c*x**2

fit f(x) "datafile.txt" using "X":"Y" via a, b, c

...some plotting commands etc...

      

with this, gnuplot shows strange behavior:

  • when i run the script as-is it throws the following error:

    Undefined value during function evaluation
    "myscriptfile.gnuplot", line 5: error during fit
    
          

  • when i move line set terminal png

    after line fit

    it works without issue.

  • usually, I load this at the beginning of the wizard script containing format templates and additional data processing routines. it also gives me the above error message even with the moved command set terminal

    .

since this is just the first part of processing my data, I really need it to work with the master script ... I've already tried to set the initial guesses, FIT_LIMIT and load it from the gnuplot environment. I am using gnuplot 4.6.5.

Does anyone know how to solve this or how fit

gets influenced by other teams? or is it some kind of error?

edit: uploaded a stripped-down version of scripts and datafiles to here . with scaled-down data files, the calculated matches are not consistent with the measured points, but with the complete data they make.

+3


source to share


1 answer


I'm not sure what the real bug is, but it seems to have something to do with your use using "PHEAT":"RHOT"

, although it should be fine.

I could reproduce your error with minimal customization:

Data file test.dat

:

A B
1 2
2 3 
3 4

      

and the file test.gp

:



f(x) = a*x**2 + b*x + c
fit f(x) 'test.dat' using "A":"B" via a,b,c

      

If I call this file with gnuplot test.gp

, I get the same error as you. It doesn't show up if I use using 1:2

. If I paste the code into an interactive terminal, the error also appears, but only once. If I repeat the command again fit

, it works fine. I will report this as a bug.

In the script you posted, I was also able to fix this using using 9:8

instead using "PHEAT":"RHOT"

. In addition, you must delete the first line of the data file, which can be executed on the fly with tail

, so that you can leave the statements using

plot

unchanged. Thus, you can use:

fit rhotside(x) "< tail -n +2 testdata.txt" using 9:8 via rhot0, rhot1, rhot2
fit rcoldside(x) "< tail -n +2 testdata2.txt" using 9:8 via rcold0, rcold1, rcold2

      

+1


source







All Articles