フィルターのクリア

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

19 ビュー (過去 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 Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by