Effacer les filtres
Effacer les filtres

How can I specify different colors for different groups of data in correlation heatmap?

25 vues (au cours des 30 derniers jours)
Hello,
I have a correlation heatmap and I would like all the "boxes" with -0.7<R<0.7 to be the same color (e.g. gray), so to be able to more easily visualize the others.
To do this for only one range (e.g. R<0.7), I used caxis, but it does not allow to specify multiple ranges.
This looks like it would be an easy fix, but I am pretty new to Matlab and I don't seem to be able to figure out anything.
Thanks for your input!
Rosalba
  3 commentaires
Rosalba Gaudiuso
Rosalba Gaudiuso le 15 Mai 2020
Hi,
Thanks for your answer.
I ended up setting all the -0.7<R<0.7 values = 0 with a relational operator and then just plotting the heatmap as such.
Definitely not the most elegant solution, but for a total beginner it kinda works. :)

Connectez-vous pour commenter.

Réponse acceptée

Devineni Aslesha
Devineni Aslesha le 18 Mai 2020
Hi Rosalba,
Here is the way to map the boxes with range -0.7<R<0.7 to the same colour.
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus','ColorVariable','Age','ColorMethod','median');
xh = h.Colormap > -0.7 & h.Colormap < 0.7;
[rowIdx, colIdx] = find(xh == 1);
h.Colormap(rowIdx, colIdx) = 0.5;
For more information, refer the following links.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by