Omega
Omega

Reputation: 33

Plotting fit in gnuplot log($1):($2) defining xrange

I have a question regarding plotting a exponential fit in Gnuplot and having the y-axis set in logscale. I am using Gnuplot 4.6.3. I will present the few ways I have tried setting a range to fit in:

The function I want to fit on the data is f(x)=a+b*x

The first:

set log y
f(x)=a+b*x
fit [4:8] f(x) 'CT2A_OH_R_log.dat' using (log($1)):($2) via a,b

Resutls:

         Read 15 points
         Skipped 15 points outside range [x=4:8]
         No data to fit
         error during fit

The second:

fit f(x) 'CT2A_OH_R_log.dat' using (log($1)):($2) via a,b

Results:

Final set of parameters              Asymptotic Standard Error
a          =16.9858                  +/- 6.299          (37.08%)
b          =-8.43215                 +/- 3.502          (41.53%)
gnuplot> plot 'CT2A_OH_R_log.dat', f(x) via a,b 

Obviously the fit is ridiculous but this is the only way I know of that actually gives me a fit. I know the problem most likely lies within the defining of the xrange when fitting but what else can I write there to fix this?

Below I will show image of my plot (f(x) is not showing as it is plotted in the negative area.)

Upvotes: 1

Views: 1617

Answers (1)

Tom Solid
Tom Solid

Reputation: 2344

'cause a logscale of the y axis requires the logarithm of the y axis during the fit ;-)

fit [4:8] f(x) 'CT2A_OH_R_log.dat' u 1:(log($2)) via a,b

NOTE

If you want to use the logarithm based on 10, you have to use log($2)/log(10) or log10($2).

Upvotes: 1

Related Questions