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

39 vues (au cours des 30 derniers jours)
Mel A
Mel A le 27 Nov 2022
Réponse apportée : Voss le 30 Nov 2022
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 commentaires
Mel A
Mel A le 29 Nov 2022
Thank you @Mathieu NOE.
Mathieu NOE
Mathieu NOE le 30 Nov 2022
My pleasure !

Connectez-vous pour commenter.

Réponse acceptée

Voss
Voss le 30 Nov 2022
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])

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by