How to make the correlation values appear at a mapcolor?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to do the mapcolor of my correlation matrix, is it possible to make the correlations values appear at the mapcolor?
figure;
imagesc(RPEARSONIDHma,[-1 1])
colorbar
set(gca,'YTick', [1:11],'YTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'})
set(gca,'XTick', [1:11],'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'})
set(gcf,'Colormap',autumn)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/309335/image.png)
0 Kommentare
Antworten (1)
Jayanti
am 10 Okt. 2024
Hi Julia,
You can use the “text” function to display the values of the correlation matrix in “mapcolor”. This function places text annotations at specified locations on the plot.
To display every value of the correlation matrix at “mapcolor”, use the "for" loop to iterate over the matrix. Below is the code you can refer to use “text” function.
text(j, i, sprintf('%.2f', RPEARSONIDHma(j, i)), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle', ...
'Color', 'k');
Here i and j are the number of rows and columns of the correlation matrix “RPEARSONIDHma”. “sprintf” will format the value of correlation matrix to two decimal places. “HorizontalAlignment” and “VerticalAlignment” will display the text value at the center with a black color.
I am also attaching MathWorks documentation on “text” for your reference:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots 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!