next up previous contents index
Next: 7. Mailing lists, updates, Up: 6. Cook-book Previous: 6.19 Color patterns on   Contents   Index


6.20 Custom map 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 one’s 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 and arcs of circles. This is how your symbol will look when a size of 1 inch is chosen. Figure 6.20 illustrates a new symbol we will call volcano.

Figure 6.20: Making a new volcano symbol for GMT
\begin{figure}\centering\epsfig{figure=eps/GMT_volcano.eps}\end{figure}

(2) After designing the symbol we will encode it using a simple set of rules. In our case we describe our volcano using no more than 4 possible constructs:


 

$x_0$ $y_0$ M [ -Gfill ] [ -Wpen ] Startnew element at $x_0$, $y_0$

$x_1$ $y_1$ D Draw straight line from current point to $x_1$, $y_1$

$x_0$ $y_0$ $r$ $\Delta\alpha$ C [ -Gfill ] [ -Wpen ] Drawsingle circle of radius $r$ around $x_0$, $y_0$ in steps of $\Delta\alpha$$^{o}$

$x_0$ $y_0$ $r$ $\alpha_1$ $\alpha_2$ $\Delta\alpha$ A Drawarc segment of radius $r$ from angle $\alpha_1$ to $\alpha_2$every $\Delta\alpha$$^{o}$

The optional -G and -–W can be used to hardwire the color fill and pen for segments. By default the segments are painted based on the values of the command line settings.

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





-0.5    -0.5    M
-0.2    0    D
-0.1    0.173205081    0.2    240    300    2    A
0    0    D
0.3    -0.5    D
-0.05    0.15    0.1    5    C
0.15    0.3    0.075    5    C
0.325    0.4    0.05    10    C
0.45    0.45    0.025    10    C





The values refer to positions and dimensions illustrated in Figure 6.20 above. (3) Given a proper definition file we use the supplied $AWK-script make_symbol to create a custom $AWK-script that will read locations and sizes of the desired symbols and replace them with line-drawings like the one in the figure but translated and scaled accordingly. The output is a multi-segment file (see Appendix B) which may be plotted with psxy or psxyz.

We are now ready to give it a try. Based on the hotspot locations in the file hotspots.d (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 $AWK-script volcano.awk and psxy. Note that you must first transform the coordinates using mapproject prior to running the $AWK-script. Without further discussion we also make a definition for a multi- colored bulls-eye symbol:





0    -0.7    M    -W0.5p/255/0/0p
0    0.7    D
-0.7    0    M    -W0.5p/255/0/0p
0.7    0    D
0    0    0.45    5    C    -Gp0/12
0    0    0.45    5    C    -W0.25p
0    0    0.35    5    C    -G255/255/0 -W0.25p
0    0    0.25    5    C    -Gp0/9
0    0    0.25    5    C    -W0.25p
0    0    0.15    5    C    -G255/255/0 -W0.25p
0    0    0.05    5    C    -G255 -W0.25p





Here is our final map script:





$AWK -f make_symbol < volcano.def >! volcano.awk
$AWK -f make_symbol < bullseye.def >! bullseye.awk
cat << EOF >! hotspots.d
55.5    -21.0    0.25
63.0    -49.0    0.25
-12.0    -37.0    0.25
-28.5    29.34    0.25
48.4    -53.4    0.25
155.5    -40.4    0.25
-155.5    19.6    0.5
-138.1    -50.9    0.25
-153.5    -21.0    0.25
-116.7    -26.3    0.25
-16.5    64.4    0.25
EOF
pscoast -R0/360/-90/90 -JR180/9i -B60/30:."Hotspot Islands and Cities": -G0/150/0 -S200/200/255 \
   -Dc -A5000 -K -U"Example 20 in Cookbook" >! example_20.ps
mapproject -R0/360/-90/90 -JR -Di hotspots.d | $AWK -f volcano.awk | psxy -R0/9/0/9 -Jx1i -O -K \
   -M -W0.25p -G255/0/0 -L >> example_20.ps
cat << EOF >! cities.d
286    40.45    0.8
31.15    30.03    0.8
115.49    -31.58    0.8
EOF
mapproject -R0/360/-90/90 -JR -Di cities.d | $AWK -f bullseye.awk | psxy -R0/9/0/9 -Jx -O \
   -M >> example_20.ps
\rm -f volcano.awk bullseye.awk hotspots.d cities.d





which produces the plot in Figure 6.21.

Figure 6.21: Using custom symbols in GMT
\begin{figure}\centering\epsfig{figure=eps/GMT_example_20.eps}\end{figure}

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, unlike the built-in symbols in GMT, can be used with the built-in patterns (Appendix E). Other approaches are also possible, of course.


next up previous contents index
Next: 7. Mailing lists, updates, Up: 6. Cook-book Previous: 6.19 Color patterns on   Contents   Index
Paul Wessel 2001-04-18