Gnuplot:在对数刻度中使用拟合

Raf*_*tro 5 graphics gnuplot approximation

我需要做一个线性近似。但是,它必须是对数刻度。

这是我的gnuplot脚本:

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"
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

显然,这种近似是错误的。谁能帮我修复它。我在Google中找不到任何东西。

and*_*ras 4

Gnuplot 正确地将您的数据拟合到您提供的函数——一条直线。

问题在于,对 y 轴使用对数刻度并不会缩放数据,而只是缩放数据的绘制方式。

尝试将其拟合为幂律:

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"
Run Code Online (Sandbox Code Playgroud)