Select cells in heatmap

2 ビュー (過去 30 日間)
Ilyass Boukhari
Ilyass Boukhari 2020 年 11 月 29 日
コメント済み: Ilyass Boukhari 2020 年 12 月 4 日
I created a heatmap with given values using the code below
cdata = [values of temperature]
xvalues = [0,1,2,3,etc.]
yvalues = [0,1,2,3,etc.]
h = heatmap(xvalues,yvalues,cdata)
I need a code to automatically select cells above a limit. (for example, select cells above value 500)
I am looking to highlight the cell with a simple cross on top or a different color, like green. it is not essential how they are highlighted so I am happy to hear any other suggestion
Thank you in advance

回答 (1 件)

Divija Aleti
Divija Aleti 2020 年 12 月 4 日
Hi Ilyass,
You can change the 'ColorLimits' property of the HeatmapChart so that all the values of 'cdata' that are equal to and above the upper limit will have the same color. To specify this color, you can append its RGB values as a row vector to the Colormap of your choice.
For example, have a look at this example code and its output, where the Colormap chosen was 'autumn' and all the values equal to and greater than 60 are highlighted in green :
cdata = [45 60 32; 43 54 76; 32 94 68; 23 95 58];
xvalues = {'Small','Medium','Large'};
yvalues = {'Green','Red','Blue','Gray'};
mymap = [autumn; 0 1 0]; % Green - [0 1 0]
h = heatmap(xvalues,yvalues,cdata,'Colormap',mymap);
h.ColorLimits = [20 60];
h.Title = 'T-Shirt Orders';
h.XLabel = 'Sizes';
h.YLabel = 'Colors';
Output:
Hope this helps!
  1 件のコメント
Ilyass Boukhari
Ilyass Boukhari 2020 年 12 月 4 日
hello and thanks for helping!
In your example, is there any way to highlight green in the middlerange only?(example 40 to 45 in green, and all the rest in 'autumn')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by