stats can help you to do some statistical works easily. For example, correlation coefficient:
Take a look of chapter “Stats” in gnuplot manual first.
stats data using 5:4 name "A"
datashould be replaced with your data file or data variable.
Now, all statistics data have been generated automatically and ready to be used.
“A” is to be set as prefix.
For example, variable
A_correlation is the correlation coefficient value between col 5 & 4.
Update: Sorry, it’s correlation coefficient, not R2.
Add a label to show correlation coefficient on the plot:
set label 1 sprintf("r = %4.2f",A_correlation) at graph 0.1, graph 0.85
||correlation coefficient between x and y values|
||A corresponding to a linear fit y = Ax + B|
||B corresponding to a linear fit y = Ax + B|
So we can define a linear equation
y = mx + c to draw it:
plot line_fit(x) title 'Linear Fit'