2

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 Commented Jul 31, 2016 at 7:17

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.