2012-05-04 73 views
2

我有一個包含三列的數據文件。我想繪製(第一,第二),並使用第三來製作彩色地圖。也就是說,平原中的每個點的顏色取決於第三列中的值。Gnuplot和Mathematica中的顏色映射

使用gnuplot的,我可以很容易地做到這一點:

gnuplot> set palette rgbformulae 33,13,10 
plot "output.dat" using 1:2:3 with points palette 

對於一組數據,我得到的是這樣的: enter image description here

現在,有在數學這樣做的一個簡單的方法是什麼?

+2

對於未來的Mathematica相關問題,您可以嘗試[Mathematica.SE](http://mathematica.stackexchange.com)。大部分的Mathematica活動已經移到那裏。您的問題將會被更快注意到,並會得到更多回復。 – Szabolcs

+0

謝謝你提及。下次會做。 – stupidity

+1

@stupidity如果你想包括圖例,你可以看看[這個問題]的答案(http://mathematica.stackexchange.com/questions/1300/listplot-with-each-point-a- (Mathematica.SE)(http://mathematica.stackexchange.com/) – Heike

回答

2

您可以從基本圖形構造它:

data = RandomReal[1, {20, 3}]; 

(* rescale 3rd column to be between 0 and 1, if needed *) 
data[[All, 3]] = Rescale[data[[All, 3]]]; 

Graphics[{PointSize[.03], {ColorData["ThermometerColors"][#3], Point[{#1, #2}]} & @@@ data}] 

Mathematica graphics

關於彩條:

內置彩條的功能是不是很好。你可以閱讀鄰接它here。有一個替代實施hereMy question here也可能有用。

+0

非常感謝您的回答和示範。然而,我用這些數據產生了我之前包含的情節。但所有的點似乎都是紅色的。這就像第三點是不變的,但情況並非如此,它從0到100不等。我真的很感激任何想法。 – stupidity

+0

好的沒關係,我已經做到了:Graphics [{PointSize [.02],{ColorData [「Rainbow」, Rescale [#3,{0,100},{0,1}]],Point [{ #1,#2}]}&@@@ DATA}] .....非常感謝 – stupidity

+0

@stupidity是的,那就是解決方案。我不得不離開昨天,沒有時間更新。對於那個很抱歉。我現在更新了這篇文章。 – Szabolcs