(20) Custom plot symbols¶

One is often required to make special maps that shows the distribution of certain features but one would prefer to use a custom symbol instead of the built-in circles, squares, triangles, etc. in the GMT plotting programs psxy and psxyz. Here we demonstrate one approach that allows for a fair bit of flexibility in designing ones own symbols. The following recipe is used when designing a new symbol.

1. Use psbasemap (or engineering paper!) to set up an empty grid that goes from -0.5 to +0.5 in both x and y. Use ruler and compass to draw your new symbol using straight lines, arcs of circles, and stand-alone geometrical objects (see psxy man page for a full description of symbol design). In this Section we will create two new symbols: a volcano and a bulls eye.
1. After designing the symbol we will encode it using a simple set of rules. In our case we describe our volcano and bulls eye using these three freeform polygon generators:

r C [ -Gfill ] [ -Wpen ] Draw M [ -Gfill ] [ -Wpen ] Start new element at ,

D Draw straight line from current point to , around (, )

r A Draw arc segment of radius r from angle to

We also add a few stand-alone circles (for other symbols, see psxy man page):

r C [ -Gfill ] [ -Wpen ] Draw r c [ -Gfill ] [ -Wpen ] Draw single circle of radius r around ,

The optional -G and -W can be used to hardwire the color fill and pen for segments (use - to disallow fill or line for any specific feature). By default the segments are painted based on the values of the command line settings.

Manually applying these rules to our volcano symbol results in a definition file volcano.def:

Without much further discussion we also make a definition file bullseye.def for a multi-colored bulls eye symbol. Note that the symbol can be created beyond the -0.5 to +0.5 range, as shown by the red lines. There is no limit in GMT to the size of the symbols. The center, however, will always be at (0,0). This is the point to which the coordinates in psxy refers.

The values refer to positions and dimensions illustrated in the Figure above.

2. Given proper definition files we may now use them with psxy or psxyz.

We are now ready to give it a try. Based on the hotspot locations in the file hotspots.txt (with a 3rd column giving the desired symbol sizes in inches) we lay down a world map and overlay red volcano symbols using our custom-built volcano symbol and psxy. We do something similar with the bulls eye symbols. Without the -G option, however, they get the colors defined in bullseye.def.

Here is our final map script that produces the Figure:

#!/bin/bash
#		GMT EXAMPLE 20
#
# Purpose:	Extend GMT to plot custom symbols
# GMT modules:	pscoast, psxy
# Unix progs:	rm
#
# Plot a world-map with volcano symbols of different sizes at hotspot locations
# using table from Muller et al., 1993, Geology.
ps=example_20.ps

gmt pscoast -Rg -JR9i -Bx60 -By30 -B+t"Hotspot Islands and Hot Cities" -Gdarkgreen -Slightblue \
-Dc -A5000 -K > $ps gmt psxy -R -J @hotspots.txt -Skvolcano -O -K -Wthinnest -Gred >>$ps

# Overlay a few bullseyes at NY, Cairo, Perth, and Montevideo

cat > cities.txt << END
74W	40.45N	0.5
31.15E	30.03N	0.5
115.49E	31.58S	0.5
56.16W	34.9S	0.5
END

gmt psxy -R -J cities.txt -Skbullseye -O >> \$ps

rm -f cities.txt


Using custom symbols in GMT.

Given these guidelines you can easily make your own symbols. Symbols with more than one color can be obtained by making several symbol components. E.g., to have yellow smoke coming out of red volcanoes we would make two symbols: one with just the cone and caldera and the other with the bubbles. These would be plotted consecutively using the desired colors. Alternatively, like in bullseye.def, we may specify colors directly for the various segments. Note that the custom symbols (Appendix [app:N]), unlike the built-in symbols in GMT, can be used with the built-in patterns (Appendix [app:E]). Other approaches are also possible, of course.