How can I show the correation coefficient R in the figure plot?
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2017-12-25
编辑:Star Strider
2017-12-25
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!