필터 지우기
필터 지우기

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

조회 수: 36 (최근 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

댓글을 달려면 로그인하십시오.

채택된 답변

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