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

21 次查看(过去 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