How to add gray to out of range in the colormap?

22 ビュー (過去 30 日間)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota 2021 年 11 月 18 日
コメント済み: Mathieu NOE 2021 年 11 月 18 日
Hi,
How to add gray color to out of range colormap, inorder to have bettter visulaization. In the following code, I need gray color for values which are not between 10 to 60.
imagesc(xFocP,yFocP,Ax_map);
colormap jet;
colorbar;
caxis([10 60])

採用された回答

DGM
DGM 2021 年 11 月 18 日
You might try something like this:
[x y z] = peaks(100);
surf(x,y,z);
shading flat
camlight
numcolors = 64;
g = [1 1 1]*0.8;
cmap = parula(numcolors);
cmap = [g; cmap; g];
cextents = [-4 5];
offset = range(cextents)*(size(cmap,1)/numcolors - 1)/2;
caxis(cextents + [-offset offset])
colormap(cmap)
colorbar

その他の回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 11 月 18 日
coming too late in the show ....
hello
my 2 cents suggestion :
% dummy data
N = 25;
Z = peaks(N);
Z = Z*5+35;
ZZ = Z;
ind = find(Z<10 | Z>60);
ZZ(ind) = 0;
% plot
figure
imagesc((1:N),(1:N),ZZ);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n = 128; % dark grey => decrease n; light grey => increase n;
tmp = [n n n]/255; % grey color
mymap = [tmp;jet(255)]; % my colormap
colormap(mymap);
hcb=colorbar('ver'); % colorbar handle
hcb.Limits = [10 60];
hcb.FontSize = 12;
hcb.Title.String = "Range";
hcb.Title.FontSize = 15;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6 件のコメント
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota 2021 年 11 月 18 日
Perfect and thank you.
Mathieu NOE
Mathieu NOE 2021 年 11 月 18 日
My pleasure

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by