next up previous contents index
Next: 7.21 Time-series of RedHat Up: 7. Cook-book Previous: 7.19 Color patterns on   Contents   Index

7.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 deccription of symbol design). This is how your symbol will look when a size of 1 inch is chosen. Figure 7.20 illustrates a new symbol we will call volcano.

    Figure 7.20: Making a new volcano symbol for GMT.

  2. After designing the symbol we will encode it using a simple set of rules. In our case we describe our volcano using these three freeform polygon generators:


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

    $x_1$ $y_1$ D Draw straight line from current point to $x_1$, $y_1$ around ($x_0$, $y_0$)

    $x_0$ $y_0$ $r$ $\alpha_1$ $\alpha_2$ A Drawarc segment of radius $r$ from angle $\alpha_1$ to $\alpha_2$

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

     $x_0$ $y_0$ $r$ c [ -Gfill ] [ -Wpen ] 		 Drawsingle circle of radius $r$ around $x_0$, $y_0$ 

    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 symbol results in a definition file volcano.def:

    #    $Id: volcano.def,v 1.5 2004/04/13 21:32:27 pwessel Exp $
    #    Definition file for a volcano symbol
    #    To be used with psxy as -Skvolcano/<size>.
    #    The symbol will be painted and drawn given the
    #    -G -L -W options on the psxy command line.
    -0.5    -0.5    M
    -0.2    0    D
    -0.1    0.173205081    0.4    240    300    A
    0.3    -0.5    D
    -0.5    -0.5    D
    -0.05    0.15    0.2    c
    0.15    0.3    0.15    c
    0.325    0.4    0.1    c
    0.45    0.45    0.05    c

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

  3. Given a proper definition file we may now use it 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 volcano symbol and psxy. Without further discussion we also make a definition for a multi- colored bulls-eye symbol:

#    $Id: bullseye.def,v 1.4 2004/04/13 21:32:27 pwessel Exp $
#    Segment info file for bullseye symbol
#    These instructions are intended for make_symbol
#    which will generate an awk-script that creates
#    multiple-segment output describing the desired
#    symbol at the chosen size.  The symbol will be
#    painted drawn given the -G  -W options for each
#    segment.
0    -0.7    M    -W0.5p,red
0    0.7    D
-0.7    0    M    -W0.5p,red
0.7    0    D
0    0    0.9    c    -Gp0/12
0    0    0.9    c    -W0.25p
0    0    0.7    c    -Gyellow -W0.25p
0    0    0.5    c    -Gp0/9
0    0    0.5    c    -W0.25p
0    0    0.3    c    -Gyellow -W0.25p
0    0    0.1    c    -Gwhite -W0.25p

Here is our final map script:

#        GMT EXAMPLE 20
#        $Id: job20.csh,v 1.6 2004/04/13 21:39:49 pwessel Exp $
# Purpose:    Extend GMT to plot custom symbols
# GMT progs:    pscoast, psxy
# Unix progs:    rm
# Plot a world-map with volcano symbols of different sizes
# on top given locations and sizes in hotspots.d

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

pscoast -Rg -JR180/9i -B60/30:."Hotspot Islands and Cities": -Gdarkgreen -Slightblue \
   -Dc -A5000 -K -U"Example 20 in Cookbook" >!

psxy -R -J hotspots.d -Skvolcano -O -K -W0.25p -Gred >>

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

cat << EOF >! cities.d
286    40.45    0.8
31.15    30.03    0.8
115.49    -31.58    0.8

psxy -R -J cities.d -Skbullseye -O >>

\rm -f hotspots.d cities.d .gmt*

which produces the plot in Figure 7.21.

Figure 7.21: 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 N), 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.21 Time-series of RedHat Up: 7. Cook-book Previous: 7.19 Color patterns on   Contents   Index
Paul Wessel 2004-10-01