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

조회 수: 22 (최근 30일)
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
Rosalba Gaudiuso
Rosalba Gaudiuso 2020년 5월 15일
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. :)

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

채택된 답변

Devineni Aslesha
Devineni Aslesha 2020년 5월 18일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by