在Matlab中创建相关图 [英] Create a correlation graph in Matlab
本文介绍了在Matlab中创建相关图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图模仿这张图:
如果我有一个相关矩阵,我该如何创建一个这样的输出?
If I have a correlation matrix how can I create an output like this?
推荐答案
一个 nxn
相关矩阵 M
和一个向量 L
长度 n
包含每个垃圾箱的标签,您可以使用类似以下的内容:
If you have an n x n
correlation matrix M
, and a vector L
of length n
containing the label for each bin, you can use something like the following:
imagesc(M); % plot the matrix
set(gca, 'XTick', 1:n); % center x-axis ticks on bins
set(gca, 'YTick', 1:n); % center y-axis ticks on bins
set(gca, 'XTickLabel', L); % set x-axis labels
set(gca, 'YTickLabel', L); % set y-axis labels
title('Your Title Here', 'FontSize', 14); % set title
colormap('jet'); % set the colorscheme
colorbar on; % enable colorbar
旋转的x轴标签并不重要,但MATLAB Central File Exchange包含一些解决方案。
Rotating x-axis labels is not trivial, but the MATLAB Central File Exchange contains some solutions.
这篇关于在Matlab中创建相关图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文