天天看點

matlab熱度圖确定色标_MATLAB:更改我的熱圖的顔色

matlab熱度圖确定色标_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];

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

解決方案

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.