2012-05-04 70 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