MATLAB: Changing color for my heat maps

♀尐吖头ヾ 提交于 2019-12-13 02:57:05

问题


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];

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 doesn't seem to do the trick for me


回答1:


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

HA.Colormap = parula(64);

(parula is the default color map for figures) or

HA.Colormap = hot(64);

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

help graph3d

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

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.



来源:https://stackoverflow.com/questions/48801006/matlab-changing-color-for-my-heat-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!