How can I show the correation coefficient R in the figure plot?
3 views (last 30 days)
Show older comments
I want to show the correlation coefficient value i.e R in the figure plot. I have used [R,P,RL,RU] = corrcoef(___) command, then I used scatter plot command. Using figure plot tool, I have done basic fitting but the problem is I am not able to show R-value in figure plot. Please help me.
0 Comments
Answers (1)
Star Strider
on 25 Dec 2017
Edited: Star Strider
on 25 Dec 2017
Use a text (link) object. Choose the (x,y) coordinates where you want it to appear, then after you plot your data:
text(x, y, sprintf('R = %.2f', R))
Experiment to get the result you want.
EDIT — To add your ‘R’ value to a legend entry:
R_1 = 0.42;
R_2 = 0.21;
figure(1)
plot(rand(1,20), rand(1,20), 'pg', rand(1,20), rand(1,20), 'pr')
legend(sprintf('Data_1 (R = %.2f)',R_1), sprintf('Data_2 (R = %.2f)',R_2))
0 Comments
See Also
Categories
Find more on Discrete Data Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!