필터 지우기
필터 지우기

How to make colormaps like the attached colorbar?

조회 수: 6 (최근 30일)
Subhodh Sharma
Subhodh Sharma 2021년 11월 20일
댓글: Subhodh Sharma 2021년 11월 20일
hello community,
I am quite new to colorbar interpolation techniques. Therefore, I would really appreciate your help in this regards.
I want to make a colormaps like the attached colorbar.
thanks in advance.
  댓글 수: 2
DGM
DGM 2021년 11월 20일
In what aspects?
Do you want it to be borderless?
Do you want it to be shaped the same?
Do you just want the same colors?
Subhodh Sharma
Subhodh Sharma 2021년 11월 20일
@DGM thanks for your response. I want the same color gradient with same colors in the colorbar. only same
colors.
I don't want borderless. I want to make a contour plot. But I can't seem to find any colormap which matches with the above one.
So, I want to make a colormap like the above one with same colors and gradient.

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

채택된 답변

DGM
DGM 2021년 11월 20일
편집: DGM 2021년 11월 20일
If you just want the colormap used in that image, this is it.
A = imread('colorbarimage.png');
np = 37; % number of points
x0 = 75; % centerline of bar
y0 = 181; % location of first breakpoint
yf = 767; % location of last breakpoint
dy = (yf-y0)/(np-2);
x = x0*ones(1,np);
y = y0-dy/2:dy:y0-dy+np*dy;
imshow(A); hold on; % show image
plot(x,y,'kx','linewidth',2) % and sample locations
% extract a colortable from the image
ct = im2double(squeeze(A(round(y),x0,:)))
ct = 37×3
0.8000 0.4510 0.4510 0.8588 0.4627 0.4627 0.9137 0.4784 0.4784 0.9686 0.4902 0.4902 1.0000 0.5216 0.5020 1.0000 0.5804 0.5020 1.0000 0.6392 0.5020 1.0000 0.6980 0.5020 1.0000 0.7569 0.5020 1.0000 0.8118 0.5020
If you want the colortable to be longer, then you can interpolate.
ctlong = interp1(1:np,ct,linspace(1,np,256))
ctlong = 256×3
0.8000 0.4510 0.4510 0.8083 0.4526 0.4526 0.8166 0.4543 0.4543 0.8249 0.4560 0.4560 0.8332 0.4576 0.4576 0.8415 0.4593 0.4593 0.8498 0.4609 0.4609 0.8581 0.4626 0.4626 0.8659 0.4648 0.4648 0.8737 0.4670 0.4670
  댓글 수: 1
Subhodh Sharma
Subhodh Sharma 2021년 11월 20일
@DGM Many thanks to you. It's exactly I was looking for. Can' thank you enough!

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

추가 답변 (1개)

KSSV
KSSV 2021년 11월 20일
편집: KSSV 2021년 11월 20일
Pick the RGB values of maximum value color you want and pick the RGB values of minimum value color you want to represent.
Let the values be:
r0 = rand ;g0 = rand ; b0 = rand ;
r1 = rand ;g1 = rand ; b1 = rand ;
M1 = [r1 g1 b1] ; % RGB valaues of color which represents maximum value
M0 = [r0 g0 b0] ; % RGB valaues of color which represents minimum value
N = 12 ; % say you want to have 64 colors/ variations between maximum and minimum
cmap = [linspace(r1,r0,N)' linspace(g1,g0,N)' linspace(b1,b0,N)'] ;
Z = peaks(100) ;
pcolor(Z)
colormap(cmap)
shading interp
colorbar

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by