Heatmap change selected cell color

17 ビュー (過去 30 日間)
Ilyass Boukhari
Ilyass Boukhari 2020 年 11 月 29 日
コメント済み: Shubham Rawat 2020 年 12 月 3 日
How do I change color to specific cells on a heatmap?
The heatmap color is 'autumn', but I need to highlight specific cells with different color
Thank you

採用された回答

Shubham Rawat
Shubham Rawat 2020 年 12 月 3 日
Hi Ilyass,
You can use 'ColorData' property of Heatmap to change the colour of the cells.
Here is example code for that:
h = heatmap([1 3 5; 2 4 6],'Colormap',autumn);
h.ColorData = [4 5 6; 1 2 3];
Hope this Helps!
  2 件のコメント
Ilyass Boukhari
Ilyass Boukhari 2020 年 12 月 3 日
Hello and thanks for coming to help!
I tried the code, but it seems it just reorders the cells in a different order (I might be wrong, so please let me know)
As an example: In a heatmap of 5x5, how to I change colour of specific cell (example only cells above 8 in black)? (and keeping the same 'autumn' map for the rest)
Hope it's clear
thanks again
Shubham Rawat
Shubham Rawat 2020 年 12 月 3 日
Hi Ilyass,
The matrix i have given here ([1 3 5; 2 4 6]) is the color indexing in autumn, and there is no black color in autumn colormap.
You may produce colormap of your choice:
mymap = autumn; %mymap is colormap matrix
mymap = [mymap; 0 0 0]; %[0 0 0] is color code for black
h = heatmap([1 2 3; 4 2 1; 5 5 5 ],'Colormap',mymap); % here last row is completely black
Hope This Helps!

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

その他の回答 (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