Select cells in heatmap
이전 댓글 표시
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
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!
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!