adding annotation(text box) to Scatter plot in matlab?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
abdur rauf
am 14 Feb. 2017
Kommentiert: abdur rauf
am 16 Feb. 2017
Hi matlab user, let i have,
x=[1 2 3 4 5 6 7];
y=[1 3 4 6 7 8 9]
scatter(x,y,'*');
r=corr(x.',y.','type','pearson');
A=r;
[rho]=corr(x.',y.','type','spearman');
B=rho;
formatspace='Pearson correlation coefficient r = %d';
str=sprintf(formatspace,A);
annotation('textbox',[.3 .5 .1 .1],'string',str)
After the operation of above code, i get the figure in the attachment. now the problem is how to pass the second text (spearman correlation coefficient rho = %d) to the variable name formatspace. Also i have used %d, which gives me result like (r=9.9124e^-01), how i can get my result like r=0.99124. thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160701/image.png)
thanks
Akzeptierte Antwort
the cyclist
am 14 Feb. 2017
Bearbeitet: the cyclist
am 14 Feb. 2017
4 Kommentare
the cyclist
am 16 Feb. 2017
Use this instead
formatspace='Pearson correlation coefficient r = %9.5f';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!