我想用颜色绘制线条,用矢量形式表示某些测量的强度。使用散射,您可以使用颜色矢量给出的颜色绘制点,但在绘图中我必须给出RGB矢量。我想知道如何将矢量映射到RGB矢量?还是有其他方法吗?
非常感谢,并告诉我,如果我没有提供一些信息
答案 0 :(得分:0)
根据您必须绘制的线条数量,一种解决方案是使用内置的色彩映射。原油示例:
intensityVector = [0.1 0.5 1]; % some intensities
% Data you want to plot
x=1:0.1:16;
data1 = zeros(1,length(x));
data2 = sin(x);
data3 = cos(x);
% Let's get an appropriate colormap
cm = colormap(hot);
close; % because colormap call opens a figure
% In order for the line to be differentiable, let's add an offset
offset=10;
figure()
hold on
plot(data1,'Color',cm(1*offset,:),'LineWidth',3);
plot(data2,'Color',cm(2*offset,:),'LineWidth',3);
plot(data3,'Color',cm(3*offset,:),'LineWidth',3);
legend({'data1','data2','data3'});