Reputation: 618
For a simple x-y scatter plot, in what way I can apply power fit curve using R or gnuplot? I have a file with two columns.
Upvotes: 3
Views: 9538
Reputation: 48430
To give an example for curve fitting with gnuplot, consider the following data set data.txt
:
0.5 0.8
2.4 9.3
3.2 37.9
4.9 68.2
6.5 155
7.8 198
The fit with a power law function may look like this:
set termoption enhanced
f(x) = a*x**b;
fit f(x) 'data.txt' via a,b
plot 'data.txt' with points title 'data points', \
f(x) with lines title sprintf('power fit curve f(x) = %.2f·x^{%.2f}', a, b)
With the terminal settings
set terminal pngcairo size 800,600 font ',12'
this gives the result
This is, of course, the most basic way to fit, the 'specialties' depend on your actual needs.
Upvotes: 9