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

36 次查看(过去 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 个评论

请先登录,再进行评论。

采纳的回答

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 CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by