How to make the correlation values appear at a mapcolor?
2 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
回答(1 个)
Jayanti
2024-10-10
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!