仅使用3种颜色的Matlab自定义颜色贴图
只想检查一下是否有可能只使用3种颜色制作自定义颜色贴图?(不需要梯度) 示例:数据范围为仅使用3种颜色的Matlab自定义颜色贴图,matlab,plot,color-mapping,Matlab,Plot,Color Mapping,只想检查一下是否有可能只使用3种颜色制作自定义颜色贴图?(不需要梯度) 示例:数据范围为0-100 所以0-33是一种颜色 34-67是另一种颜色 而68-100是另一种颜色 遵循此示例:但您将使用R=one(50,1)*t(1)而不是R=linspace(0,t(1),50) 或者更简单: 如果颜色1为t1=[r1、g1、b1]等,则 map(1:34, :) = repmat(t1, 33, 1) map(35:68, :) = repmat(t2, (67-34), 1) 等等 或 m
0-100
- 所以
是一种颜色0-33
是另一种颜色34-67
- 而
是另一种颜色68-100
R=one(50,1)*t(1)
而不是R=linspace(0,t(1),50)
或者更简单:
如果颜色1为t1=[r1、g1、b1]
等,则
map(1:34, :) = repmat(t1, 33, 1)
map(35:68, :) = repmat(t2, (67-34), 1)
等等
或
map(1:34,:)=bsxfun(@times,t,one(33,3))
等等。遵循这个例子:但是您将使用R=ones(50,1)*t(1)
而不是R=linspace(0,t(1),50)
或者更简单:
如果颜色1为t1=[r1、g1、b1]
等,则
map(1:34, :) = repmat(t1, 33, 1)
map(35:68, :) = repmat(t2, (67-34), 1)
等等
或
map(1:34,:)=bsxfun(@times,t,one(33,3))
等等。检查我的答案
您可以使用该代码并决定是否在值之间进行插值,它只有两行代码
GYR cutom彩色贴图的原始帖子中显示的结果图像
检查我的答案
您可以使用该代码并决定是否在值之间进行插值,它只有两行代码
GYR cutom彩色贴图的原始帖子中显示的结果图像
只需使用三行的颜色贴图即可。每行定义了一种颜色的R,G,B组成部分
A = randi(100,16,16); %// example data
imagesc(A) %// display matrix as image
colormap([1 0 0; 0 1 0; 0 0 1]) %// apply colormap
colorbar %// show color bar
这定义了颜色之间均匀分布的阈值。如果需要更多控件,则需要有三行以上的行,并重复某些颜色。比如说,
colormap([1 0 0; 1 0 0; 0 1 0; 0 0 1]) %// apply colormap
将为第一种颜色定义50%的阈值,第二种颜色定义75%,第三种颜色定义100%。只需使用具有三行的颜色贴图。每行定义了一种颜色的R,G,B组成部分
A = randi(100,16,16); %// example data
imagesc(A) %// display matrix as image
colormap([1 0 0; 0 1 0; 0 0 1]) %// apply colormap
colorbar %// show color bar
这定义了颜色之间均匀分布的阈值。如果需要更多控件,则需要有三行以上的行,并重复某些颜色。比如说,
colormap([1 0 0; 1 0 0; 0 1 0; 0 0 1]) %// apply colormap
将为第一种颜色定义50%的阈值,第二种颜色定义75%,第三种颜色定义100%。举个例子:
% some matrix with integer values in the range [0,100]
Z = peaks;
Z(:) = round((Z(:)-min(Z(:))) ./ range(Z(:))*100);
% show as image (with scaled color mapping)
image(Z, 'CDataMapping','scaled')
caxis([0 100]) % set axes CLim property
colormap(eye(3)) % set figure Colormap property
colorbar % show colorbar
请注意,颜色被缩放到范围[0 100],该范围映射到当前地物的颜色贴图(我们仅将其设置为三种颜色)
举个例子:
% some matrix with integer values in the range [0,100]
Z = peaks;
Z(:) = round((Z(:)-min(Z(:))) ./ range(Z(:))*100);
% show as image (with scaled color mapping)
image(Z, 'CDataMapping','scaled')
caxis([0 100]) % set axes CLim property
colormap(eye(3)) % set figure Colormap property
colorbar % show colorbar
请注意,颜色被缩放到范围[0 100],该范围映射到当前地物的颜色贴图(我们仅将其设置为三种颜色)