Fitting data to a function with Gnuplot

Put your x,y data in a file that Gnuplot can read, like a simple text file with an x,y pair on a line separated by a space.

Define the function, for example:


Do the fit:

fit gauss(x) ‘gaussTest.dat’ via a, sigma, p

Plot the output with the data:

plot ‘gaussTest.dat’ with histeps, gauss(x)


Author: Jay Jay Billings

I'm a physicist with a serious addiction to computing. Most days you can find my bumming around ORNL and Twitter.