How to plot correlation coefficient matrix plot?
280 次查看(过去 30 天)
显示 更早的评论
I want to plot a correlation coefficient matrix plot and I want to show the values at each individual box as shown in the picture. I have my my calculated correlation coeff values.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1050470/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1050470/image.png)
0 个评论
回答(1 个)
Adam Danz
2022-6-29
编辑:Adam Danz
2022-6-29
Assuming you already have the correlation matrix, use heatmap. The upper triangle can be filled with NaNs.
S = load('Data_Canada');
r = corr(S.Data)
% Replace upper triangle with NaNs
isupper = logical(triu(ones(size(r)),1));
r(isupper) = NaN
% Plot results
h = heatmap(r,'MissingDataColor','w');
labels = ["wt","hp","xy","ad","tt"];
h.XDisplayLabels = labels;
h.YDisplayLabels = labels;
另请参阅
类别
在 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!