Next: 7.21 Time-series of RedHat Up: 7. Creating GMT Graphics 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 description of symbol design). In this Section we will create two new symbols: a volcano and a bulls eye.

2. 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:

          M [ -Gfill ] [ -Wpen ] 		 Start new element at ,

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

            A 		 Drawarc segment of radius  from angle  to

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

           c [ -Gfill ] [ -Wpen ] 		 Drawsingle circle of radius  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:

       #
       #       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

   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.

       #
       #       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

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

3. 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.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. 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 Figure 7.20:

    #!/bin/sh
    #               GMT EXAMPLE 20
    #
    # 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
    ps=example_20.ps

    cat > hotspots.d << END
    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
    END

    pscoast -Rg -JR9i -B60/30:."Hotspot Islands and Cities": -Gdarkgreen -Slightblue -Dc -A5000 -K \
            -U"Example 20 in Cookbook" > $ps

    psxy -R -J hotspots.d -Skvolcano -O -K -Wthinnest -Gred >> $ps

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

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

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

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

Figure: 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: 7.21 Time-series of RedHat Up: 7. Creating GMT Graphics Previous: 7.19 Color patterns on Contents Index