2013-04-08 155 views
3

我有一組矢量,形狀爲一個n×m矩陣,我想從中計算m個疊加的n個等效圖。這很容易:在MATLAB中的Normplot顏色映射

c=rand(100,10); 
figure 
normplot(c) 

normplot自動爲每列數據着色,但我想控制它們是如何着色的。具體而言,我需要讓他們成爲灰度。第一組數據(第1列)應該是白色(或接近白色),最後一組是黑色。

+0

由於我沒有安裝Matlab的我只能給一個鏈接從MathWorks公司對應的幫助頁面:定義您自己的ColorOrder ](http://www.mathworks.de/de/help/matlab/creating_plots/defining-the-color-of-lines-for-plotting.html?searchHighlight=ColorOrder#brdjjco-1) – pwagner 2013-04-08 13:12:41

回答

3

通過獲取柄以圖線你可以是這樣的:

close all; 
n = 100; 
m = 10; 
doc=rand(n,m); 
figure; 

% obtain the handle h to the dotted lines 
h = normplot(doc); 

% define colormap 
g = colormap('gray'); 

for i = 1:m 
    %set(h([1 11 21]),'color','r') % to set color to red 
    %set(h([1 11 21]),'marker','o') % to change marker 

    % mapping into greyscale color map (g has size 64x3) 
    set(h([i i+m i+2*m]),'color',g(round(i * size(g,1)/m),:)); 
end 

enter image description here