1
votes

I am trying to fit a plot in gnuplot using logscale. I have 50000 data points. At first I fit plot in this way.

 f(x) = b + m*x
 fit f(x) "xyMSD-all-mal-cel-iso-bcm-thermo2.dat" using 1:2  via m,b

I got slope value. Then I tried to get slope value at different range as below.

 fit [30000:50000] f(x) "xyMSD-all-mal-cel-iso-bcm-thermo2.dat" using 1:2  via m,b

The above code works fine. In next attempt I tried,

 f(x) = b + m*x
 fit f(x) "xyMSD-all-mal-cel-iso-bcm-thermo2.dat" using (log($1)):(log($2)) via m,b

Above works fine too. I get the slope value. Then I tried to choose the xrange like below. This is where I have problem. It does not work.

 fit [500:5000] f(x) "xyMSD-all-mal-cel-iso-bcm-thermo2.dat" using (log($1)):(log($2)) via m,b

Is there any way to achieve this? Appreciate any help

2
"It does not work" -- What doesn't work about it? Does gnuplot give you an error? If so, what is it?mgilson
Means I dont get the fit between the specified range. For example x range from [30000:50000]. When I execute the script I get error message as { Read 9999 points Skipped 9999 points outside range [x=30000:50000] No data to fit }Vijay

2 Answers

2
votes

The range has to fit the expression, which in your case are log values. So make sure the log values are within range. For example, if your range for ($1):($2) is [500:5000], then the corresponding range for (log($1)):(log($2)) should be something like [2.69:3.69].

1
votes

Gnuplot first uses the expression on your data. Limiting the range is the second step, so in this case the logarithm of the required data points have to be in the xrange.

AND don't forget: logscale uses the logarithm based on 10 but log(x) or log($1) means logaritm based on 'e' (approx. 2.7183). To be harmonic with the logscale use function log10(x) (or log(x)/log(10)).

PS: I know that the original question had been answered previously, but I haven't got enough prestige to append my useful comment about the log() function as a comment.