2015-04-06 102 views
0

我想繪製線條,顏色代表某種矢量形式的測量強度。使用散點圖可以用顏色矢量給出的顏色繪製點,但在繪圖中我必須給出RGB矢量。我想知道如何將我的矢量映射到RGB矢量?或者還有其他一些方法嗎?在Matlab中繪製各種顏色的線條R2014b

非常感謝,並告訴我,如果我不給一些信息

回答

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'});