2
votes

My question is regarding how I can plot multiple data lines with each having their own fit in one plot?

gnuplot> plot 'data.dat', f(x) via a,b
gnuplot> replot 'data2.dat', f(x) via a,b 

This doesn't allow me to plot multiple fits even when I redefine the fitting for f(x) to fit data2.dat. I also tried using another name for the function for data2.dat eg. g(x) and then fitting that but then still the fit for the first one dissappears. So I only get one fit on the plot.

How do I get multiple data with each showing their own fit on one plot?

Please do ask if more info is needed, thanks!

1
You also need different variables for the second fit, because gnuplot saves the fit result in the global fitting variables you specify with via - Christoph

1 Answers

2
votes

You can do separate fits, then plot both files and fits. Assuming these are linear fits just for simplicity:

f(x) = a*x+b
g(x) = c*x+d

fit f(x) 'data.dat'  via a,b
fit g(x) 'data2.dat' via c,d

plot 'data.dat',  f(x),\
     'data2.dat', g(x)