Gnuplot: use scale-based fit

I need to do a linear approximation. However, it must be journal-wide.

Here is my gnuplot script:

f(x)= a*x+b
fit f(x) "d0.dat" via a,b
set logscale x
set logscale y
plot "d0.dat" with points lt rgb "#ff0000" title "Points", \
f(x) with lines lt rgb "#ff00ff" title "Approximation"

enter image description here

Clearly, the approximation is wrong. Can anyone help me fix this. I did not find anything on Google.

+4
source share
1 answer

Gnuplot correctly adjusts your data to the function you provide - a straight line.

The problem is that using the logarithm scale for the y axis does not scale the data - exactly the way the data is displayed.

Try setting it to power law:

f(x)= a*x**b
fit f(x) "d0.dat" via a,b
set logscale x
set logscale y
plot "d0.dat" with points lt rgb "#ff0000" title "Points", \
f(x) with lines lt rgb "#ff00ff" title "Approximation"
+4
source

Source: https://habr.com/ru/post/1535122/


All Articles