Masud Rahman
Masud Rahman

Reputation: 1062

Matlab HeatMap color issue

I am using HeatMap object which provides a HeatMap like the image below.

Heatmap I created

I am using this command:

hmo=HeatMap(data,'ColumnLabels',collabels,'ColorMap','copper','RowLabels',rowlabels,'ColumnLabelsRotate',45,'Symmetric',true,'Standardize','ROW');

However, I need the color scale (at the right) to be 0 to 1, and lightest color should represent the lowest value and vice versa. Any help will be appreciated.

Upvotes: 0

Views: 456

Answers (1)

brodoll
brodoll

Reputation: 1881

To make the lightest colour represent lowest values you need to reverse the colormap order. You can do so by getting the colormap matrix and flipping it:

cmap = colormap('copper');
newcmap = flipud(cmap);

So instead of specifying the string 'copper' in the heat map call, you should pass newcmap.

To adjust the colorbar limits after the heat map creation, I believe you need to use the CLim option:

set(gca,'CLim', [0 1])

Upvotes: 2

Related Questions