# Example 8
# An example using the fit command to fit a function
# to a datafile.

reset

# Functional forms to be fitted -- parabolas
f(x) = a * x**2 + b * x + c
g(x) = d * x**2 + e * x + f

# First of all, fit data neglecting errorbars
fit f(x) 'examples/example8.dat' via a,b,c

# Now fit data taking errorbars into account
fit g(x) 'examples/example8.dat' using 1:2:3 via d,e,f

# Plot the resulting functions
set width 12
set key bottom left
set xlabel 'x'
set ylabel 'y'
set xrange [0:8]
set yrange [0:5]
set term eps
set output 'examples/eps/example8.eps'
plot 'examples/example8.dat' with yerrorbars, \
     f(x), g(x)

# Produce a gif copy
set term gif
set dpi 154
set output 'examples/eps/example8.gif'
refresh
