Matlab调整热图轴和颜色

时间:2015-12-04 14:43:19

标签: matlab

我正在尝试创建一个我不太熟悉的热图。我有一个大的矩阵形式:

One=
[0 2 4 6 8
 2 1 3 5 6
 4 5 8 3 1
 6 2 7 4 8
 8 3 9 5 4]

我想创建一个热图,使最上面的行和最左边的列是轴。 到目前为止,我已经做到了这一点:

figure(1)
Plot = One;     
colormap('hot');   
imagesc(Plot);       

我还注意到,在'热'色图中,小数字非常暗,大数字是白色。有没有办法扭转这种局面?

2 个答案:

答案 0 :(得分:3)

这是一个好的开始:

One = ...
[0 2 4 6 8
 2 1 3 5 6
 4 5 8 3 1
 6 2 7 4 8
 8 3 9 5 4];

figure();
imagesc(One(1,:), One(:,1), One(2:end,2:end));
get(gca(), 'ydir', 'normal')
colormap(flipud(hot()));
colorbar();

enter image description here

请注意x& y轴大于数据,因此可能需要排除One(1,1)

figure();
imagesc(One(1,2:end), One(2:end,1), One(2:end,2:end));
get(gca(), 'ydir', 'normal')
colormap(flipud(hot()));
colorbar();

enter image description here

答案 1 :(得分:3)

使用hot函数生成色彩映射,然后使用flipud将其翻转:

colormap(flipud(hot))

默认情况下,这会产生64种颜色。如果要指定其他数字,例如128,请使用

colormap(flipud(hot(128)))
相关问题