上文链接教学提取颜色。为此,以下就是有单点颜色RGB或者十六进制HEX。
%https://color.adobe.com/zh/create/image-gradient这个也可以使用。
使用以下代码即可得到自己想要的颜色条colormap了。
实例应用:
十六进制颜色转RGB函数引用:
Chad Greene (2024). rgb2hex and hex2rgb (https://www.mathworks.com/matlabcentral/fileexchange/46289-rgb2hex-and-hex2rgb), MATLAB Central File Exchange. Retrieved .
函数包制作:MATLAB | MATLAB配色不够用 全网最全的colormap补充包来啦_matlab color-CSDN博客
(3 封私信 / 3 条消息) 如何在matlab里设置一个从透明到红色的colorbar?- 知乎 (zhihu.com)
总之,他有很多成熟的颜色包。
clear;clc;close all; %https://color.adobe.com/zh/create/image-gradient
morecolor8 =['#C6E6FD',
'#8DCDFD',
'#1B9BFC'
];
morecolor81 = hex2rgb(morecolor8);
CM = morecolor81 ;n=256;
CMX=linspace(0,1,size(CM,1));
CMXX=linspace(0,1,256)';
CM=[interp1(CMX,CM(:,1),CMXX,'pchip'), ...
interp1(CMX,CM(:,2),CMXX,'pchip'), ...
interp1(CMX,CM(:,3),CMXX,'pchip')];
morecolor81_500 =CM;
figure
set(gcf,'position',[50 50 850 500],'color','w')
subplot(211)
for i = 1:3
x =[i i+1 i+1 i];
y =[0 0 1 1];
h=fill(x,y,morecolor81(i,:));
set(h,'facecolor',morecolor81(i,:),'edgecolor',morecolor81(i,:))
hold on
text(i+0.5,0.5,num2str(roundn(morecolor81(i,:)',-1)),'color','w')
text(i+0.3,0.6,'R:','color','w')
text(i+0.3,0.5,'G:','color','w')
text(i+0.3,0.4,'B:','color','w')
end
axis off
save morecolor8.mat morecolor81
% export_fig('morecolor.jpg','-r600')
title('morecolor8','FontSize',30)
su=subplot(212, 'Position',[0.1800 0.1100 0.7750 0.2972]);
for i = 1:256
xx =[i i+1 i+1 i];
yy =[0 0 1 1];
h=fill(xx,yy,morecolor81_500(i,:));
set(h,'facecolor',morecolor81_500(i,:),'edgecolor',morecolor81_500(i,:))
hold on
end
title('morecolor8\_500','FontSize',30)
axis off
save morecolor8_500.mat morecolor81_500
export_fig('morecolor8_500.jpg','-r600')