Friday, April 3, 2009

2D color maps in gnuplot 4.2

I was working on a school project about MLP and I had some output data in this form:

[x, y, category]
------------------
-4.82 -2.906 -1.0
-3.224 2.244 -1.0
-1.342 0.876 1.0
3.383 -2.237 -1.0
-1.665 -4.269 -1.0
-0.154 -0.042 1.0
2.148 1.662 0.0
------------------

And I wanted to make a colored map where the color of the points (first two columns) is dependent on category (the last column). Cause it's not a trivial task I wanted to share with solution I found. Here you can find the answer: http://www.gnuplot.info/faq/faq.html#SECTION000511000000000000000

For those who don't like to leave my blog there is the code:
gnuplot> set view map
gnuplot> set pm3d map
gnuplot> splot "test_map.dat" with points palette pt 9
And here is an example of what it can do:

Of course you can define your own colors or shapes of the points.