如果您有 n x n 相关矩阵 M ,并且长度为 n 的向量 L 包含每个bin的标签,则可以使用如下内容:
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
imagesc(myMatrix);
colormap(jet);
colorbar;
% then to set the axis titles you'll have to use
% Please note the curly braces for the cell array
labelNames = {'USA','NASDAQ','Dow Jones'};
set(gca,'XTickLabel',labelNames); % gca gets the current axis
set(gca,'YTickLabel'labelNames); % gca gets the current axis
3 回答
如果您有
n x n
相关矩阵M
,并且长度为n
的向量L
包含每个bin的标签,则可以使用如下内容:旋转x轴标签并非易事,但MATLAB中央文件交换包含some solutions .
添加到@Thomas C. G.的答案,我会使用:
不幸的是,AFAIK,使文本标签垂直,如图所示is a bit harder . 也许其他人有相反的知识 .
要将矩阵绘制为图像,您只需调用两个函数:
colormap函数定义用于渲染图像的颜色模式 . 您发布的图像使用的是"jet"色彩映射 .
要显示图像旁边的色标,请使用colorbar功能 .