Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot chi squared on graph - gnuplot

I'm new to GNUplot but I need it for my lab work. I have a series of data I need to fit. It's a simple thing, I made the fit and it works. I also managed to print the parameters on the grap, but how do I plot the value of the chi-squared and degrees of freedom too? labels on plot

like image 326
Doctor Watson Avatar asked Dec 02 '25 06:12

Doctor Watson


1 Answers

I found the solution by myself. GNUPlot doesn't explicitly tell the name it gives to the chi-squared variable, but it prints the degrees of freedom (FIT_NDF) and the rms of residuals (FIT_STDFIT) for every fit. The rms of residuals in the square root of chi-squared, therefore I used this:

     set fit errorvariables
     fit f(x) data using @c0c1 yerror via a,b
     set label sprintf("a = %2.6f +/- %2.6f",a,a_err) @graph
     set label sprintf("b = %2.6f +/- %2.6f",b,b_err) @graph2
     set label sprintf("DOF = %.0f", FIT_NDF) @dof
     chi2=(FIT_STDFIT*FIT_STDFIT)
     set label sprintf("{/Symbol c}^2 = %.5f", chi2) @chi2
     plot data using @c0c1 with yerrorbars title "C0-C1", f(x)

And now it works

like image 113
Doctor Watson Avatar answered Dec 04 '25 18:12

Doctor Watson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!