简体   繁体   中英

xrange limiting in logscale plot in gnuplot

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

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] .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM