Select cells in heatmap

10 vues (au cours des 30 derniers jours)
Ilyass Boukhari
Ilyass Boukhari le 29 Nov 2020
Commenté : Ilyass Boukhari le 4 Déc 2020
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

Réponses (1)

Divija Aleti
Divija Aleti le 4 Déc 2020
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 commentaire
Ilyass Boukhari
Ilyass Boukhari le 4 Déc 2020
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')

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by