# Example 8
# An example of fitting functions 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
# Now fit a spline through the data
spline h() 'examples/example8.dat'

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

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