Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > os > by-pkgid > 4b194777eaf705e440bb2ce282d32772 > files > 566

GMT-doc-4.5.3-3.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>7.20 Custom plot symbols</TITLE>
<META NAME="description" CONTENT="7.20 Custom plot symbols">
<META NAME="keywords" CONTENT="GMT_Docs">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="GMT_Docs.css">

<LINK REL="next" HREF="node142.html">
<LINK REL="previous" HREF="node140.html">
<LINK REL="up" HREF="node121.html">
<LINK REL="next" HREF="node142.html">
</HEAD>

<BODY  bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html4630"
  HREF="node142.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4624"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4618"
  HREF="node140.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4626"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4628"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4631"
  HREF="node142.html">7.21 Time-series of RedHat</A>
<B> Up:</B> <A NAME="tex2html4625"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4619"
  HREF="node140.html">7.19 Color patterns on</A>
 &nbsp; <B>  <A NAME="tex2html4627"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4629"
  HREF="node256.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0015200000000000000000"></A>
<A NAME="24580"></A>
<BR>
7.20 Custom plot symbols
</H1>

<P>
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 <A NAME="tex2html1458"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> plotting programs
<A NAME="tex2html1459"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25475"></A> and <A NAME="tex2html1460"
  HREF="../man/psxyz.html"><I><B>psxyz</B></I></A><A NAME="25480"></A>.  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.

<OL>
<LI>Use <A NAME="tex2html1461"
  HREF="../man/psbasemap.html"><I><B>psbasemap</B></I></A><A NAME="25485"></A> (or
engineering paper!) to set up an empty grid that goes from
-0.5 to +0.5 in both <I>x</I> and <I>y</I>.  Use ruler and
compass to draw your new symbol using straight lines,
arcs of circles, and stand-alone geometrical objects (see <A NAME="tex2html1462"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25490"></A> man page for
a full description of symbol design).  In this Section we will create two new symbols:
a volcano and a bulls eye.

<P>

<DIV ALIGN="CENTER">
   <DIV ALIGN="CENTER"><IMG
 WIDTH="632" HEIGHT="323" ALIGN="BOTTOM" BORDER="0"
 SRC="img181.png"
 ALT="\includegraphics{scripts/GMT_volcano}">
</DIV>
</DIV>

<P>
</LI>
<LI>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:

<P>
<PRE><TT>
 <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$"> <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$"> <B>M</B> [ <B>-G</B><I>fill</I> ] [ <B>-W</B><I>pen</I> ] 		 Start new element at <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$">, <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$"> 
<BR><IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img184.png"
 ALT="$x_1$"> <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img185.png"
 ALT="$y_1$"> <B>D</B> 		 Draw straight line from current point to <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img184.png"
 ALT="$x_1$">, <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img185.png"
 ALT="$y_1$"> around (<IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$">, <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$">) 
<BR><IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$"> <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$"> <IMG
 WIDTH="11" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
 SRC="img18.png"
 ALT="$r$"> <IMG
 WIDTH="21" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img186.png"
 ALT="$\alpha_1$"> <IMG
 WIDTH="21" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img187.png"
 ALT="$\alpha_2$"> <B>A</B> 		 Drawarc segment of radius <IMG
 WIDTH="11" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
 SRC="img18.png"
 ALT="$r$"> from angle <IMG
 WIDTH="21" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img186.png"
 ALT="$\alpha_1$"> to <IMG
 WIDTH="21" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img187.png"
 ALT="$\alpha_2$">
</TT></PRE> 

<P>
We also add a few stand-alone circles (for other symbols, see <A NAME="tex2html1463"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25499"></A> man page):

<P>
<PRE><TT>
 <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$"> <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$"> <IMG
 WIDTH="11" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
 SRC="img18.png"
 ALT="$r$"> <B>c</B> [ <B>-G</B><I>fill</I> ] [ <B>-W</B><I>pen</I> ] 		 Drawsingle circle of radius <IMG
 WIDTH="11" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
 SRC="img18.png"
 ALT="$r$"> around <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img182.png"
 ALT="$x_0$">, <IMG
 WIDTH="18" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
 SRC="img183.png"
 ALT="$y_0$"> 
<BR>
</TT></PRE> 

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

<P>
Manually applying these rules to our volcano symbol results in a
definition file <U>volcano.def</U>:

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#
#       Definition file for a volcano symbol
#       To be used with psxy as -Skvolcano/&lt;size&gt;.
#       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
</PRE>
<BR CLEAR="ALL">
<HR>
<P>
Without much further discussion we also make a definition file <U>bullseye.def</U> 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
<A NAME="tex2html1464"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> to the size of the symbols. The center, however, will always be at (0,0). This is the point to which the
coordinates in <A NAME="tex2html1465"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25516"></A> refers.

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#
#       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
</PRE>
<BR CLEAR="ALL">
<HR>
<P>
The values refer to positions and dimensions illustrated in the Figure above.

<P>
</LI>
<LI>Given proper definition files we may now use them with <A NAME="tex2html1466"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25522"></A> or <A NAME="tex2html1467"
  HREF="../man/psxyz.html"><I><B>psxyz</B></I></A><A NAME="25527"></A>.
</LI>
</OL>

<P>
We are now ready to give it a try.  Based on the hotspot
locations in the file <U>hotspots.d</U> (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 <A NAME="tex2html1468"
  HREF="../man/psxy.html"><I><B>psxy</B></I></A><A NAME="25533"></A>. We do something similar with the bulls eye symbols.
Without the <B>-G</B> option, however, they get the colors defined in <U>bullseye.def</U>.

<P>
Here is our final map script that produces Figure&nbsp;<A HREF="#fig:GMT_example_20">7.20</A>:

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#!/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 &gt; hotspots.d &lt;&lt; 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" &gt; $ps

psxy -R -J hotspots.d -Skvolcano -O -K -Wthinnest -Gred &gt;&gt; $ps

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

cat &gt; cities.d &lt;&lt; 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 &gt;&gt; $ps

rm -f hotspots.d cities.d .gmt*
</PRE>
<BR CLEAR="ALL">
<HR>
<DIV ALIGN="CENTER"><A NAME="fig:GMT_example_20"></A><A NAME="25541"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure:</STRONG>
Using custom symbols in <A NAME="tex2html1455"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A>.</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="553" HEIGHT="382" ALIGN="BOTTOM" BORDER="0"
 SRC="img188.png"
 ALT="\includegraphics[scale=0.5]{scripts/example_20}"></DIV></TD></TR>
</TABLE>
</DIV>

<P>
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 <U>bullseye.def</U>, we may
specify colors directly for the various segments.  Note that
the custom symbols (Appendix&nbsp;<A HREF="node238.html#app:N">N</A>), unlike the built-in symbols in <A NAME="tex2html1469"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A>, can
be used with the built-in patterns (Appendix&nbsp;<A HREF="node200.html#app:E">E</A>).  Other
approaches are also possible, of course.
<A NAME="24640"></A>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html4630"
  HREF="node142.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4624"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4618"
  HREF="node140.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4626"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4628"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4631"
  HREF="node142.html">7.21 Time-series of RedHat</A>
<B> Up:</B> <A NAME="tex2html4625"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4619"
  HREF="node140.html">7.19 Color patterns on</A>
 &nbsp; <B>  <A NAME="tex2html4627"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4629"
  HREF="node256.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2010-07-14
</ADDRESS>
</BODY>
</HTML>