<!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>2.2 Plotting text strings</TITLE> <META NAME="description" CONTENT="2.2 Plotting text strings"> <META NAME="keywords" CONTENT="GMT_Tutorial"> <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_Tutorial.css"> <LINK REL="next" HREF="node39.html"> <LINK REL="previous" HREF="node34.html"> <LINK REL="up" HREF="node33.html"> <LINK REL="next" HREF="node39.html"> </HEAD> <BODY bgcolor="#ffffff"> <!--Navigation Panel--> <A NAME="tex2html942" HREF="node39.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html936" HREF="node33.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html930" HREF="node37.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html938" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html940" HREF="node63.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html943" HREF="node39.html">2.3 Exercises</A> <B> Up:</B> <A NAME="tex2html937" HREF="node33.html">2. SESSION TWO</A> <B> Previous:</B> <A NAME="tex2html931" HREF="node37.html">2.1.3 More exercises</A> <B> <A NAME="tex2html939" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html941" HREF="node63.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <H1><A NAME="SECTION00420000000000000000"> 2.2 Plotting text strings</A> </H1> <P> In many situations we need to annotate plots or maps with text strings; in <A NAME="tex2html164" HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> this is done using <A NAME="tex2html165" HREF="../man/pstext.html"><I><B>pstext</B></I></A><A NAME="2206"></A>. Apart from the common switches, there are 7 options that are particularly useful (Table <A HREF="#tbl:pstext">2.4</A>). <P> <BR><P></P> <DIV ALIGN="CENTER"><A NAME="1589"></A> <TABLE> <CAPTION><STRONG>Table 2.4:</STRONG> Some of the most frequently used options in <A NAME="tex2html154" HREF="../man/pstext.html"><I><B>pstext</B></I></A><A NAME="2220"></A>.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><TABLE CELLPADDING=3 BORDER="1"> <TR><TD ALIGN="CENTER" COLSPAN=1><FONT SIZE="-1"> <I>Option</I></FONT></TD> <TD ALIGN="CENTER" COLSPAN=1><FONT SIZE="-1"> <I>Purpose</I></FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-C</B></FONT><FONT SIZE="-1"><I>dx</I>/</FONT><FONT SIZE="-1"><I>dy</I> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Spacing between text and the text box (see <B>-W</B>) </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-D</B></FONT><FONT SIZE="-1"><I>dx</I>/</FONT><FONT SIZE="-1"><I>dy</I> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Offsets the projected location of the strings </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-G</B></FONT><FONT SIZE="-1"><I>fill</I> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Sets the color of the text </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-L</B> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Lists the font ids and exits </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-N</B> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Deactivates clipping at the borders </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-S</B></FONT><FONT SIZE="-1"><I>pen</I> </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Selects outline font and sets pen attributes </FONT></TD> </TR> <TR><TH ALIGN="LEFT"><FONT SIZE="-1"> <B>-W</B>[</FONT><FONT SIZE="-1"><I>fill</I>][</FONT><FONT SIZE="-1"><B>o</B>[</FONT><FONT SIZE="-1"><I>pen</I>]] </FONT></TH> <TD ALIGN="LEFT"><FONT SIZE="-1"> Paint the text box; draw the outline if </FONT><FONT SIZE="-1"><B>o</B> is appended (also see <B>-C</B>) </FONT></TD> </TR> </TABLE><FONT SIZE="-1"> <A NAME="tbl:pstext"></A></FONT></DIV></TD></TR> </TABLE> </DIV><P></P> <BR> <P> <DIV ALIGN="CENTER"><A NAME="fig:GMT_pstext_clearance"></A><A NAME="2225"></A> <TABLE> <CAPTION ALIGN="BOTTOM"><STRONG>Figure 2.1:</STRONG> Relationship between the text box and the extra clearance.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><IMG WIDTH="210" HEIGHT="82" ALIGN="BOTTOM" BORDER="0" SRC="img28.png" ALT="\includegraphics{scripts/GMT_pstext_clearance}"></DIV></TD></TR> </TABLE> </DIV> <P> The input data to <A NAME="tex2html166" HREF="../man/pstext.html"><I><B>pstext</B></I></A><A NAME="2230"></A> is expected to contain the following information: <BR><A NAME="1590"></A> <P> <I>x y size angle fontno justify text</I> <BR> <P> The <I>size</I> argument is the font size in points, the <I>angle</I> is the angle (measured counterclockwise) between the text's baseline and the horizontal, <I>justify</I> indicates which point on the text-string should correspond to the given <I>x, y</I> location, and <I>text</I> is the text string or sentence to plot. Figure <A HREF="#fig:GMT_pstext_justify">2.2</A> illustrates these concepts and shows the relevant two-character codes used for justification. <A NAME="973"></A> <A NAME="974"></A> <P> <DIV ALIGN="CENTER"><A NAME="fig:GMT_pstext_justify"></A><A NAME="2240"></A> <TABLE> <CAPTION ALIGN="BOTTOM"><STRONG>Figure 2.2:</STRONG> Justification (and corresponding character codes) for text strings.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><IMG WIDTH="241" HEIGHT="79" ALIGN="BOTTOM" BORDER="0" SRC="img29.png" ALT="\includegraphics{scripts/GMT_pstext_justify}"></DIV></TD></TR> </TABLE> </DIV> <P> The text string can be one or several words and may include octal codes for special characters and escape-sequences used to select subscripts or symbol fonts. The escape sequences that are recognized by <A NAME="tex2html167" HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> are given in Tables <A HREF="#tbl:escape">2.5</A> and <A HREF="#tbl:scand">2.6</A>. <A NAME="979"></A> <A NAME="980"></A> <A NAME="981"></A> <A NAME="982"></A> <A NAME="983"></A> <A NAME="984"></A> <A NAME="985"></A> <P> <BR><P></P> <DIV ALIGN="CENTER"><A NAME="999"></A> <TABLE> <CAPTION><STRONG>Table:</STRONG> <A NAME="tex2html160" HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> text escape sequences.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><TABLE CELLPADDING=3 BORDER="1"> <TR><TD ALIGN="CENTER" COLSPAN=1><FONT SIZE="-1"> <I>Code</I></FONT></TD> <TD ALIGN="CENTER" COLSPAN=1><FONT SIZE="-1"> <I>Effect</I></FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @~</FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Turns symbol font on or off </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @+ </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Turns superscript on or off </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @- </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Turns subscript on or off </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @# </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Turns small caps on or off </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @_ </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Turns underline on or off </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @%<I>fontno</I>% </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Switches to another font; @%% resets to previous font </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @:<I>size</I>: </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Switches to another font size; @:: resets to previous size </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @;<I>color</I>; </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Switches to another font color; @;; resets to previous color </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @! </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Creates one composite character of the next two characters </FONT></TD> </TR> <TR><TD ALIGN="LEFT"><FONT SIZE="-1"> @@ </FONT></TD> <TD ALIGN="LEFT"><FONT SIZE="-1"> Prints the @ sign itself </FONT></TD> </TR> </TABLE><FONT SIZE="-1"> <A NAME="tbl:escape"></A></FONT></DIV></TD></TR> </TABLE> </DIV><P></P> <BR> <P> Note that these escape sequences (as well as octal codes) can be used anywhere in <A NAME="tex2html168" HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> including in arguments to the <B>-B</B> option. A chart of octal codes can be found in Appendix F in the <A NAME="tex2html169" HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> technical reference book. For accented European characters you must set <B>CHAR_ENCODING</B> to ISOLatin1 in your <U>.gmtdefaults4</U> file. <P> We will demonstrate <A NAME="tex2html170" HREF="../man/pstext.html"><I><B>pstext</B></I></A><A NAME="2259"></A> with the following script: <P> <PRE> cat << EOF | pstext -R0/7/0/5 -Jx1i -P -B1g1 -GDarkOrange | ghostview - 1 1 30 0 4 BL It's P@al, not Pal! 1 2 30 0 4 BL Try @%33%ZapfChancery@%% today 1 3 30 0 4 BL @~D@~g@-b@- = 2@~pr@~G@~D@~h. 1 4 30 0 4 BL University of Hawaii at M@!a\225noa EOF </PRE> <P> <A NAME="1008"></A> <P> Here we have used the ``here document'' notation in <I>UNIX</I>: The <IMG WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="img30.png" ALT="$<$"><IMG WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0" SRC="img30.png" ALT="$<$"> EOF will treat the following lines as the input file until it detects the word EOF. We pipe the <I>PostScript</I> directly through <I>ghostview</I><A NAME="2265"></A> (the - tells <I>ghostview</I><A NAME="2268"></A> that piping is happening). <P> <BR><P></P> <DIV ALIGN="CENTER"><A NAME="1025"></A> <TABLE> <CAPTION><STRONG>Table 2.6:</STRONG> Shortcuts for some European characters.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><TABLE CELLPADDING=3 BORDER="1"> <TR><TD ALIGN="LEFT"><I>Code</I></TD> <TD ALIGN="LEFT"><I>Effect</I></TD> <TD ALIGN="LEFT"><I>Code</I></TD> <TD ALIGN="LEFT"><I>Effect</I></TD> </TR> <TR><TD ALIGN="LEFT">@E</TD> <TD ALIGN="LEFT">Æ</TD> <TD ALIGN="LEFT">@e</TD> <TD ALIGN="LEFT">æ</TD> </TR> <TR><TD ALIGN="LEFT">@O</TD> <TD ALIGN="LEFT">Ø</TD> <TD ALIGN="LEFT">@o</TD> <TD ALIGN="LEFT">ø</TD> </TR> <TR><TD ALIGN="LEFT">@A</TD> <TD ALIGN="LEFT">Å</TD> <TD ALIGN="LEFT">@a</TD> <TD ALIGN="LEFT">å</TD> </TR> <TR><TD ALIGN="LEFT">@C</TD> <TD ALIGN="LEFT">Ç</TD> <TD ALIGN="LEFT">@c</TD> <TD ALIGN="LEFT">ç</TD> </TR> <TR><TD ALIGN="LEFT">@N</TD> <TD ALIGN="LEFT">Ñ</TD> <TD ALIGN="LEFT">@n</TD> <TD ALIGN="LEFT">ñ</TD> </TR> <TR><TD ALIGN="LEFT">@U</TD> <TD ALIGN="LEFT">Ü</TD> <TD ALIGN="LEFT">@u</TD> <TD ALIGN="LEFT">ü</TD> </TR> <TR><TD ALIGN="LEFT">@s</TD> <TD ALIGN="LEFT">ß</TD> <TD ALIGN="LEFT"> </TD> <TD ALIGN="LEFT"> </TD> </TR> </TABLE> <A NAME="tbl:scand"></A></DIV></TD></TR> </TABLE> </DIV><P></P> <BR> <P> <HR> <!--Navigation Panel--> <A NAME="tex2html942" HREF="node39.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html936" HREF="node33.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html930" HREF="node37.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html938" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html940" HREF="node63.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html943" HREF="node39.html">2.3 Exercises</A> <B> Up:</B> <A NAME="tex2html937" HREF="node33.html">2. SESSION TWO</A> <B> Previous:</B> <A NAME="tex2html931" HREF="node37.html">2.1.3 More exercises</A> <B> <A NAME="tex2html939" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html941" HREF="node63.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> Paul Wessel 2011-02-27 </ADDRESS> </BODY> </HTML>