GMT: Changing the color of a symbol within a xy file

This is a very specific problem with Generic Mapping Tools which I didn’t find well documented: if you map certain symbols to a list of coordinates specified in COORDINATES.xy, you can specify that subsets of those coordinates are mapped to symbols in different colors in two ways:

  1.  You add a column containing numerical values that map to colors in COLORS.cpt. This option is illustrated in my earlier post on making WALS maps.
  2. You add coloring instructions directly to your COORDINATES.xy file by adding a line such as > -Gred. The hard-to-find part here was the fact that you need to prefix the color option by >.

In this case, your COORDINATES.xy file might look like this:

8.74, 9.72
11.80, 29.28
-8.65, 141.52
66.40, 17.43
70.67, 130.91
-29.71, 19.08
43.50, -88.50
-2.91, -68.91
42.04, 43.99
-10.61, 150.73
> -Gwhite -Wblack
56.80, -120.35
-13.81, -65.63
7.60, 6.04
> -Ggray -Wblack
-16.27, 168.01
-16.17, 168.14
-16.31, 168.05
-17.70, 168.38
-15.43, 167.24

You can then use this file, for example, with the following commands to produce a world map displaying these coordinates:

pscoast -R-20/340/-70/80 -Dl -A100/0/1 -JQ9.5i -W -B -K > MAP.ps
psxy COORDINATES.xy   -R -J -O -Sc0.25c -i2,1 -Gblack >> MAP.ps

The result looks like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.