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일

0 개 추천

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')

댓글을 달려면 로그인하십시오.

카테고리

제품

질문:

2020년 11월 29일

댓글:

2020년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by