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

22 Ansichten (letzte 30 Tage)
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 Kommentare
Rosalba Gaudiuso
Rosalba Gaudiuso am 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. :)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Devineni Aslesha
Devineni Aslesha am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by