Sophie

Sophie

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

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.21 Time-series of RedHat stock price</TITLE>
<META NAME="description" CONTENT="7.21 Time-series of RedHat stock price">
<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="node143.html">
<LINK REL="previous" HREF="node141.html">
<LINK REL="up" HREF="node121.html">
<LINK REL="next" HREF="node143.html">
</HEAD>

<BODY  bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html4644"
  HREF="node143.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4638"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4632"
  HREF="node141.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4640"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4642"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4645"
  HREF="node143.html">7.22 World-wide seismicity the</A>
<B> Up:</B> <A NAME="tex2html4639"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4633"
  HREF="node141.html">7.20 Custom plot symbols</A>
 &nbsp; <B>  <A NAME="tex2html4641"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4643"
  HREF="node256.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0015210000000000000000"></A>
<A NAME="24642"></A>
<BR>
7.21 Time-series of RedHat stock price
</H1>

<P>
As discussed in Section&nbsp;<A HREF="node40.html#sec:timeaxis">4.4.3</A>, the annotation of time-series
is generally more complicated due to the extra degrees of freedom afforded
by the dual annotation system.  In this example we will display the trend
of the stock price of RedHat (RHAT) from their initial public offering until
late 2006.  The data file is a comma-separated table and the records
look like this:
<PRE>
Date,Open,High,Low,Close,Volume,Adj.Close*
12-Mar-04,17.74,18.49,17.67,18.02,4827500,18.02
11-Mar-04,17.60,18.90,17.37,18.09,7700400,18.09
</PRE>
Hence, we have a single header record and various prices in USD for each
day of business.  We will plot the trend of the opening price as a red line superimposed on
a yellow envelope representing the low-to-high fluctuation during each day.  We
also indicate when and at what cost Paul Wessel bought a few shares, and zoom in
on the developments since 2004; in the inset we label the time-axis in Finnish in honor
of Linus Thorvalds.  Because the time coordinates are Y2K-challenged and the
order is backwards (big units of years come <I>after</I> smaller units like
days) we must change the default input/output formats used by <A NAME="tex2html1471"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A>. Finally,
we want to prefix prices with the $ symbol to indicate the currency.  Here is
how it all comes out:

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#!/bin/sh
#               GMT EXAMPLE 21
#
# Purpose:      Plot a time-series
# GMT progs:    gmtset, gmtconvert, minmax, psbasemap, psxy 
# Unix progs:   cut, echo
#
ps=example_21.ps

# File has time stored as dd-Mon-yy so set input format to match it

gmtset INPUT_DATE_FORMAT dd-o-yy PLOT_DATE_FORMAT o ANNOT_FONT_SIZE_PRIMARY +10p
gmtset TIME_FORMAT_PRIMARY abbreviated CHAR_ENCODING ISOLatin1+

# Pull out a suitable region string in yyy-mm-dd format

minmax -fT -I50 -C -H RHAT_price.csv &gt; RHAT.info
w=`cut -f1 RHAT.info`
e=`cut -f2 RHAT.info`
s=`cut -f3 RHAT.info`
n=`cut -f4 RHAT.info`
R="-R$w/$e/$s/$n"

# Lay down the basemap:

psbasemap $R -JX9i/6i -Glightgreen -K -U"Example 21 in Cookbook" -Bs1Y/WSen \
   -Bpa3Of1o/50WSen:=\$::."RedHat (RHAT) Stock Price Trend since IPO": &gt; $ps

# Plot main window with open price as red line over yellow envelope of low/highs

gmtset OUTPUT_DATE_FORMAT dd-o-yy
gmtconvert -F0,2 -f0T -Hi RHAT_price.csv &gt; RHAT.env
gmtconvert -F0,3 -f0T -I -Hi RHAT_price.csv &gt;&gt; RHAT.env
psxy -R -J -Gyellow -O -K RHAT.env &gt;&gt; $ps
psxy -R -J RHAT_price.csv -H -Wthin,red -O -K &gt;&gt; $ps

# Draw P Wessel's purchase price as line and label it.  Note we temporary switch
# back to default yyyy-mm-dd format since that is what minmax gave us.

echo "05-May-00 0" &gt; RHAT.pw
echo "05-May-00 300" &gt;&gt; RHAT.pw
psxy -R -J RHAT.pw -Wthinner,- -O -K &gt;&gt; $ps
echo "01-Jan-99 25" &gt; RHAT.pw
echo "01-Jan-07 25" &gt;&gt; RHAT.pw
psxy -R -J RHAT.pw -Wthick,- -O -K &gt;&gt; $ps
gmtset INPUT_DATE_FORMAT yyyy-mm-dd
echo "$w 25 12 0 17 LB Wessel purchase price" | pstext -R -J -O -K -D2i/0.05i -N &gt;&gt; $ps
gmtset INPUT_DATE_FORMAT dd-o-yy

# Get smaller region for insert for trend since 2004

R="-R2004T/$e/$s/40"

# Lay down the basemap, using Finnish annotations and place the insert in the upper right:

gmtset TIME_LANGUAGE fi
psbasemap $R -JX6i/3i -Bpa3Of3o/10:=\$:ESw -Bs1Y/ -Glightblue -O -K -X3i -Y3i &gt;&gt; $ps
gmtset TIME_LANGUAGE us

# Again, plot close price as red line over yellow envelope of low/highs

psxy -R -J -Gyellow -O -K RHAT.env &gt;&gt; $ps
psxy -R -J RHAT_price.csv -H -Wthin/red -O -K &gt;&gt; $ps

# Draw P Wessel's purchase price as dashed line

psxy -R -J RHAT.pw -Wthick,- -O &gt;&gt; $ps

# Clean up after ourselves:

rm -f RHAT.* .gmt*
</PRE>
<BR CLEAR="ALL">
<HR>
<P>
which produces the plot in Figure&nbsp;<A HREF="#fig:GMT_example_21">7.21</A>, suggesting Wessel
has missed a few trains if he had hoped to cash in on the Internet bubble...

<P>

<DIV ALIGN="CENTER"><A NAME="fig:GMT_example_21"></A><A NAME="25557"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.21:</STRONG>
Time-series of RedHat stock price since IPO.</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="566" HEIGHT="404" ALIGN="BOTTOM" BORDER="0"
 SRC="img189.png"
 ALT="\includegraphics[scale=0.5]{scripts/example_21}"></DIV></TD></TR>
</TABLE>
</DIV>

<P>
<A NAME="24651"></A>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html4644"
  HREF="node143.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html4638"
  HREF="node121.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html4632"
  HREF="node141.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html4640"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html4642"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html4645"
  HREF="node143.html">7.22 World-wide seismicity the</A>
<B> Up:</B> <A NAME="tex2html4639"
  HREF="node121.html">7. Creating GMT Graphics</A>
<B> Previous:</B> <A NAME="tex2html4633"
  HREF="node141.html">7.20 Custom plot symbols</A>
 &nbsp; <B>  <A NAME="tex2html4641"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html4643"
  HREF="node256.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2010-07-14
</ADDRESS>
</BODY>
</HTML>