Revision: 6993
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6993&view=rev
Author:   jdh2358
Date:     2009-03-18 16:40:26 +0000 (Wed, 18 Mar 2009)

Log Message:
-----------
use urllib2 for yahoo finace; more cleanups to demo

Modified Paths:
--------------
    trunk/matplotlib/examples/pylab_examples/finance_work2.py
    trunk/matplotlib/lib/matplotlib/finance.py

Modified: trunk/matplotlib/examples/pylab_examples/finance_work2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/finance_work2.py   2009-03-18 
16:07:19 UTC (rev 6992)
+++ trunk/matplotlib/examples/pylab_examples/finance_work2.py   2009-03-18 
16:40:26 UTC (rev 6993)
@@ -139,8 +139,8 @@
 ax1.plot(r.date, rsi, color=fillcolor)
 ax1.axhline(70, color=fillcolor)
 ax1.axhline(30, color=fillcolor)
-ax1.fill_between(r.date, rsi, 70, facecolor=fillcolor, where=(rsi>=70))
-ax1.fill_between(r.date, rsi, 30, facecolor=fillcolor, where=(rsi<=30))
+ax1.fill_between(r.date, rsi, 70, where=(rsi>=70), facecolor=fillcolor, 
edgecolor=fillcolor)
+ax1.fill_between(r.date, rsi, 30, where=(rsi<=30), facecolor=fillcolor, 
edgecolor=fillcolor)
 ax1.text(0.6, 0.9, '>70 = overbought', va='top', transform=ax1.transAxes, 
fontsize=textsize)
 ax1.text(0.6, 0.1, '<30 = oversold', transform=ax1.transAxes, 
fontsize=textsize)
 ax1.set_ylim(0, 100)
@@ -181,7 +181,7 @@
 
 volume = (r.close*r.volume)/1e6  # dollar volume in millions
 vmax = volume.max()
-poly = ax2t.fill_between(r.date, volume, 0, facecolor=fillcolor, 
label='Volume')
+poly = ax2t.fill_between(r.date, volume, 0, label='Volume', 
facecolor=fillcolor, edgecolor=fillcolor)
 ax2t.set_ylim(0, 5*vmax)
 ax2t.set_yticks([])
 
@@ -195,14 +195,14 @@
 ema9 = moving_average(macd, nema, type='exponential')
 ax3.plot(r.date, macd, color='black', lw=2)
 ax3.plot(r.date, ema9, color='blue', lw=1)
-ax3.fill_between(r.date, macd-ema9, 0, facecolor=fillcolor, alpha=0.5)
+ax3.fill_between(r.date, macd-ema9, 0, alpha=0.5, facecolor=fillcolor, 
edgecolor=fillcolor)
 
 
 ax3.text(0.025, 0.95, 'MACD (%d, %d, %d)'%(nfast, nslow, nema), va='top',
          transform=ax3.transAxes, fontsize=textsize)
 
 ax3.set_yticks([])
-# turn off tick labels, rorate them, etc
+# turn off upper axis tick labels, rotate the lower ones, etc
 for ax in ax1, ax2, ax2t, ax3:
     if ax!=ax3:
         for label in ax.get_xticklabels():

Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py  2009-03-18 16:07:19 UTC (rev 
6992)
+++ trunk/matplotlib/lib/matplotlib/finance.py  2009-03-18 16:40:26 UTC (rev 
6993)
@@ -5,7 +5,7 @@
 """
 #from __future__ import division
 import os, time, warnings
-from urllib import urlopen
+from urllib2 import urlopen
 
 try:
     from hashlib import md5
@@ -121,8 +121,10 @@
         verbose.report('Using cachefile %s for %s'%(cachename, ticker))
     else:
         if not os.path.isdir(cachedir): os.mkdir(cachedir)
+        urlfh = urlopen(url)
+
         fh = file(cachename, 'w')
-        fh.write(urlopen(url).read())
+        fh.write(urlfh.read())
         fh.close()
         verbose.report('Saved %s data to cache file %s'%(ticker, cachename))
         fh = file(cachename, 'r')


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to