MATLAB:更改我的热图的颜色 [英] MATLAB: Changing color for my heat maps

查看:3170
本文介绍了MATLAB:更改我的热图的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的示例脚本用于创建四个具有相同色标限制的热图.我以这种方式进行设置,以便区分每个热图之间的差异.但是,差异几乎不明显.目前,颜色设置在一般的蓝色范围内(浅蓝色至深蓝色).如何将其更改为冷/热配色方案?

The sample script below is for creating four heat maps with the same color scale limit. I set it this way in order for me to differentiate the differences between each heat map; however, the difference is barely noticeable. The color is currently set in a general blue range (light to darker blue). What can I do to change it to maybe a hot/cold color scheme?

cd C:\Users\Aiskya\Desktop\Subjects\total
A = dlmread('avg_data.txt')

cd C:\Users\Aiskya\Desktop\Subjects\total
B = dlmread('avg_data.txt')

cd C:\Users\Aiskya\Desktop\Subjects\total
C = dlmread('avg_data.txt')

cd C:\Users\Aiskya\Desktop\Subjects\total
D = dlmread('avg_data.txt')

minValue = min([A(:); B(:); C(:); D(:)]);
maxValue = max([A(:); B(:); C(:); D(:)]);
HA.ColorLimits = [minValue maxValue];
HB.ColorLimits = [minValue maxValue];
HC.ColorLimits = [minValue maxValue];
HD.ColorLimits = [minValue maxValue];

xvalues =  
{'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'};
yvalues = 
{'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'};

subplot(2,2,1)
HA = heatmap(xvalues,yvalues,A);
HA.Title = 'A';
HA.XLabel = 'regions';
HA.YLabel = 'regions';
HA.ColorLimits = [minValue maxValue];

共有4个子图,它们看起来都像上面的行.显示在"MATLAB热图参考"中的所有热图具有相似的颜色设置,但我找不到有关此的特定属性.感谢您的帮助!

There are a total of 4 subplots, which all look like the lines above. All the heatmaps are shown in "MATLAB heatmap reference" has a similar color setting, and I couldn't find a specific property that talks about this. I appreciate the help!

* Colorbar似乎不适合我

*Colorbar doesn't seem to do the trick for me

推荐答案

您可以使用HeatmapChart对象的Colormap属性更改使用的颜色图:

You can change the color map used using the Colormap property of the HeatmapChart object:

HA.Colormap = parula(64);

(parula是图形的默认颜色图)或

(parula is the default color map for figures) or

HA.Colormap = hot(64);

要获取MATLAB中所有默认颜色图的列表,请输入

To get a list of all default color maps in MATLAB, type

help graph3d

(滚动到显示彩色图"的位置).

(scroll to where it says "Color maps").

请注意,在命令提示符下键入HA时,您会看到HeatmapChart对象的一些属性,但不是全部.列表的底部是一个显示显示所有属性"的链接.在那里,您可以找到有关这些热图的所有可调整内容.您也可以在文档中> a>.

Note that when you type HA at the command prompt, you get to see a few of the properties of the HeatmapChart object, but not all. At the bottom of the list is a link that says "Show all properties". There you can find everything that you can tweak about these heat maps. More information is also available in the documentation.

这篇关于MATLAB:更改我的热图的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆