In Gnuplot, stats
can help you to do some statistical works easily. For example, correlation coefficient:
Take a look of chapter “Stats” in gnuplot manual first.
Use stats


data
should 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.
Correlation Coefficient
Update: Sorry, it’s correlation coefficient, not R^{2}.
Add a label to show correlation coefficient on the plot:


Linear Fit
Variable  Meaning 

STATS_correlation 
correlation coefficient between x and y values 
STATS_slope 
A corresponding to a linear fit y = Ax + B 
STATS_intercept 
B corresponding to a linear fit y = Ax + B 
So we can define a linear equation y = mx + c
to draw it:

