フィルターのクリア

Setting the color of specific cells in a heatmap that contains two types of data

52 ビュー (過去 30 日間)
Amin Kassab-Bachi
Amin Kassab-Bachi 2021 年 11 月 26 日
コメント済み: DGM 2021 年 11 月 27 日
Hi,
I created the array below in Excel, and it's perfect except that the color bar is ugly and not detailed enough.
So I've been trying to recreate it in MATLAB using the heatmap function and this is what I produced so far.
Which is almost perfect, but I need to set a separate colormap, or a separate condition for the p-value cells. I want only cells with p-value of less than 0.05 to be colored while the rest is just white or black.
Some help with this would be great.
Thanks a lot.
  2 件のコメント
dpb
dpb 2021 年 11 月 26 日
Attach your code/data to create what you have as a starting point for those here..."help us help you"
Amin Kassab-Bachi
Amin Kassab-Bachi 2021 年 11 月 26 日
Thanks for the comment.
The code
h=heatmap([1:30],["r(FCP)","r(FCP) {\it{p-value}}","{\rho}(FCP)","{\rho}(FCP) {\it{p-value}}","r(IDP)","r(IDP) {\it{p-value}}","{\rho}(IDP)","{\rho}(IDP) {\it{p-value}}"],[r_CP,rpval_CP,rho_CP,pval_CP,r_MNP,rpval_MNP,rho_MNP,pval_MNP]','Colormap',jet);
caxis([-1 1])
The Data is attached. I hope this is helpful.

サインインしてコメントする。

採用された回答

DGM
DGM 2021 年 11 月 26 日
You can use NaN to indicate out-of-range data
h = rand(10,10);
h(h<0.1) = NaN;
hh = heatmap(h);
hh.MissingDataLabel = 'h < 0.1';
colormap(jet)
The color of the excluded cells can be set using the MissingDataColor property.
  3 件のコメント
DGM
DGM 2021 年 11 月 26 日
Maybe something like this:
load CorrelationData.mat
thresh = 0.05;
pvals = [rpval_CP,pval_CP,rpval_MNP,pval_MNP]; % p-val
r = [r_CP,rho_CP,r_MNP,rho_MNP]; % idk what you call these
pvals(pvals<thresh) = NaN;
alldata = reshape([r; pvals],size(pvals,1),[]).'; % interleave and transpose
h=heatmap(1:30, ...
["r(FCP)","r(FCP) {\it{p-value}}","{\rho}(FCP)","{\rho}(FCP) {\it{p-value}}","r(IDP)","r(IDP) {\it{p-value}}","{\rho}(IDP)","{\rho}(IDP) {\it{p-value}}"], ...
alldata,'Colormap',jet);
caxis([-1 1])
colormap(parula)
Amin Kassab-Bachi
Amin Kassab-Bachi 2021 年 11 月 26 日
Brilliant! This definitely works. Many thanks for the help.

サインインしてコメントする。

その他の回答 (1 件)

Amin Kassab-Bachi
Amin Kassab-Bachi 2021 年 11 月 27 日
I used a custom colormap from here, and the result is very close to what I had in Excel. Great!

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by