How to make the correlation values appear at a mapcolor?
Mostra commenti meno recenti
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)

Risposte (1)
Jayanti
il 10 Ott 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:
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!