Custom heat maps- How to highlight a specific value in the heatmap

39 ビュー (過去 30 日間)
Mel A
Mel A 2022 年 11 月 27 日
回答済み: Voss 2022 年 11 月 30 日
I have a cell array of 6 cells (Mycell)
Each cell (i)containing 1486X492 points- each point is a value betwen 1 and -1 in decimal points.
I would like to plot this in a heatmap highligting only the points that are between 0.01 to -0.01
h = heatmap (Mycell{i});
I am not sure how to apply colour limits or any other better way to do this
Thanks
  3 件のコメント
Mel A
Mel A 2022 年 11 月 29 日
Thank you @Mathieu NOE.
Mathieu NOE
Mathieu NOE 2022 年 11 月 30 日
My pleasure !

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

採用された回答

Voss
Voss 2022 年 11 月 30 日
Maybe one of the following two approaches will be useful, depending on exactly what you want to see.
First, make up some data:
% some made-up data:
data = rand(25)*2-1; % uniform random on (-1,1)
data(randi(numel(data),[1 250])) = 0; % put some extra zeros in there
Approach 1: Use a custom colormap:
% this colormap will span values from -1 to 1
cmap = parula(200);
% make the range from -0.01 to 0.01 (i.e., the middle two rows)
% white in color, for highlighting:
cmap([100 101],:) = 1;
% create the heatmap
h = heatmap(data,'GridVisible',false);
% apply the colormap
colormap(cmap)
% apply the color limits (full range of the data)
clim([-1 1])
Approach 2: Use a standard colormap, but set the color limits to [-0.01 0.01]:
% some standard built-in colormap:
cmap = parula();
% create the heatmap
h = heatmap(data,'GridVisible',false);
% apply the colormap
colormap(cmap)
% apply the color limits (within the narrow range only
% - data outside this range map to the first or last color)
clim([-0.01 0.01])

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by