2013-04-04 414 views
1

我有一個大矩陣DAT(50000+,42)。我將這個矩陣的2行繪製在x和y軸上,並且由於單獨的行的值,繪圖點需要顏色變化。任何人都可以建議嗎?由於「顏色數據輸入必須是矩陣」錯誤,因此pcolor不適用於我。 TIApcolor散點圖matlab

X = DAT(:,21); 

Y = DAT(:,22); 

Z = DAT(:,28); 

plot(X,Y,'*'); 

hold on 

pcolor(X,Y,Z); 

hold off 
+0

如果您有機會獲得統計工具箱,然後「gscatter」將顏色由團體:http://www.mathworks.com/help/stats/gscatter.html – Dan 2013-04-04 15:03:37

回答

2

你可以考慮使用scatter()

% random sample data 
DAT = randn(30,42); 
X = DAT(:,21); 
Y = DAT(:,22); 
Z = DAT(:,28); 

scatter(X,Y,50,Z); % x,y,size,color -> size can also be a vector 
% scatter(X,Y,50,Z,'*'); % to also change the marker type 

enter image description here

1

您可以從colormap產生一個這樣的數組選擇顏色:

DAT = randn(30,42); 
X = DAT(:,21); 
Y = DAT(:,22); 
Z = DAT(:,28); 

[dummy ID]=sort(Z); 
colors=colormap(jet(length(Z))); 

figure 
for i=1:length(Z) 
plot(X(i),Y(i),'*','Color',colors(ID(i),:)); 
hold on 
end 

唯一的問題這種技術是你無法與數以百萬計,因爲環形繪製的點做的地塊,但除此之外,它就像一個魅力:

enter image description here