SF.net SVN: matplotlib:[8443] trunk/matplotlib
Revision: 8443
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8443&view=rev
Author: efiring
Date: 2010-06-20 16:46:34 + (Sun, 20 Jun 2010)
Log Message:
---
finance: restore original adjustment algorithm, but use ndarray.
A numpy recarray replaces the Bunch when asobject is True.
Additional fields are provided.
Modified Paths:
--
trunk/matplotlib/examples/pylab_examples/date_demo1.py
trunk/matplotlib/examples/pylab_examples/date_demo2.py
trunk/matplotlib/examples/pylab_examples/finance_demo.py
trunk/matplotlib/lib/matplotlib/finance.py
Modified: trunk/matplotlib/examples/pylab_examples/date_demo1.py
===
--- trunk/matplotlib/examples/pylab_examples/date_demo1.py 2010-06-20
01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/date_demo1.py 2010-06-20
16:46:34 UTC (rev 8443)
@@ -27,7 +27,7 @@
quotes = quotes_historical_yahoo(
'INTC', date1, date2)
-if not quotes:
+if len(quotes) == 0:
raise SystemExit
dates = [q[0] for q in quotes]
Modified: trunk/matplotlib/examples/pylab_examples/date_demo2.py
===
--- trunk/matplotlib/examples/pylab_examples/date_demo2.py 2010-06-20
01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/date_demo2.py 2010-06-20
16:46:34 UTC (rev 8443)
@@ -23,7 +23,7 @@
quotes = quotes_historical_yahoo('INTC', date1, date2)
-if not quotes:
+if len(quotes) == 0:
print 'Found no quotes'
raise SystemExit
Modified: trunk/matplotlib/examples/pylab_examples/finance_demo.py
===
--- trunk/matplotlib/examples/pylab_examples/finance_demo.py2010-06-20
01:34:30 UTC (rev 8442)
+++ trunk/matplotlib/examples/pylab_examples/finance_demo.py2010-06-20
16:46:34 UTC (rev 8443)
@@ -5,20 +5,18 @@
from matplotlib.finance import quotes_historical_yahoo, candlestick,\
plot_day_summary, candlestick2
-import datetime
+# (Year, month, day) tuples suffice as args for quotes_historical_yahoo
+date1 = ( 2004, 2, 1)
+date2 = ( 2004, 4, 12 )
-date1 = datetime.date( 2004, 2, 1)
-date2 = datetime.date( 2004, 4, 12 )
-
mondays = WeekdayLocator(MONDAY)# major ticks on the mondays
alldays= DayLocator() # minor ticks on the days
weekFormatter = DateFormatter('%b %d') # Eg, Jan 12
dayFormatter = DateFormatter('%d') # Eg, 12
-quotes = quotes_historical_yahoo(
-'INTC', date1, date2)
-if not quotes:
+quotes = quotes_historical_yahoo('INTC', date1, date2)
+if len(quotes) == 0:
raise SystemExit
fig = figure()
Modified: trunk/matplotlib/lib/matplotlib/finance.py
===
--- trunk/matplotlib/lib/matplotlib/finance.py 2010-06-20 01:34:30 UTC (rev
8442)
+++ trunk/matplotlib/lib/matplotlib/finance.py 2010-06-20 16:46:34 UTC (rev
8443)
@@ -11,90 +11,130 @@
from hashlib import md5
except ImportError:
from md5 import md5 #Deprecated in 2.5
+import datetime
-try: import datetime
-except ImportError:
-raise ImportError('The finance module requires datetime support
(python2.3)')
-
import numpy as np
from matplotlib import verbose, get_configdir
-from dates import date2num
-from matplotlib.cbook import Bunch
+from matplotlib.dates import date2num
+from matplotlib.cbook import iterable, is_string_like
from matplotlib.collections import LineCollection, PolyCollection
from matplotlib.colors import colorConverter
-from lines import Line2D, TICKLEFT, TICKRIGHT
-from patches import Rectangle
+from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
+from matplotlib.patches import Rectangle
from matplotlib.transforms import Affine2D
-
configdir = get_configdir()
cachedir = os.path.join(configdir, 'finance.cache')
-def parse_yahoo_historical(fh, asobject=False, adjusted=True):
+stock_dt = np.dtype([('date', object),
+ ('year', np.int16),
+ ('month', np.int8),
+ ('day', np.int8),
+ ('d', np.float), # mpl datenum
+ ('open', np.float),
+ ('close', np.float),
+ ('high', np.float),
+ ('low', np.float),
+ ('volume', np.int),
+ ('aclose', np.float)])
+
+
+def parse_yahoo_historical(fh, adjusted=True, asobject=False):
"""
-Parse the historical data in file handle fh from yahoo finance and return
-results as a list of
+Parse the historical data in file handle fh from yahoo finance.
-d, open, close, high, low, volume
+*adjusted*
+ If True (default) replace open, close, high, low, and volume with
+ their adjusted values.
+ The adjustment is by a scale factor, S = adjusted_close/close.
+ Adjusted volume is actual
SF.net SVN: matplotlib:[8444] trunk/matplotlib/lib/mpl_toolkits/axisartist/ grid_finder.py
Revision: 8444 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8444&view=rev Author: leejjoon Date: 2010-06-20 20:05:49 + (Sun, 20 Jun 2010) Log Message: --- mpl_toolkits.axisartist.grid_finder.MaxNLocator supports factor Modified Paths: -- trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py Modified: trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py === --- trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py 2010-06-20 16:46:34 UTC (rev 8443) +++ trunk/matplotlib/lib/mpl_toolkits/axisartist/grid_finder.py 2010-06-20 20:05:49 UTC (rev 8444) @@ -260,14 +260,22 @@ trim=trim, integer=integer, symmetric=symmetric, prune=prune) self.create_dummy_axis() +self._factor = None - def __call__(self, v1, v2): -self.set_bounds(v1, v2) -locs = mticker.MaxNLocator.__call__(self) -return np.array(locs), len(locs), None +if self._factor is not None: +self.set_bounds(v1*self._factor, v2*self._factor) +locs = mticker.MaxNLocator.__call__(self) +return np.array(locs), len(locs), self._factor +else: +self.set_bounds(v1, v2) +locs = mticker.MaxNLocator.__call__(self) +return np.array(locs), len(locs), None +def set_factor(self, f): +self._factor = f + class FixedLocator(object): def __init__(self, locs): self._locs = locs @@ -287,11 +295,14 @@ def __init__(self): self._fmt = mticker.ScalarFormatter() self._fmt.create_dummy_axis() +self._ignore_factor = True def __call__(self, direction, factor, values): -if factor is None: -factor = 1. -values = [v/factor for v in values] +if not self._ignore_factor: +if factor is None: +factor = 1. +values = [v/factor for v in values] +#values = [v for v in values] self._fmt.set_locs(values) return [self._fmt(v) for v in values] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8445] trunk/matplotlib/doc/faq/howto_faq.rst
Revision: 8445 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8445&view=rev Author: leejjoon Date: 2010-06-20 20:05:57 + (Sun, 20 Jun 2010) Log Message: --- remove auto_subplots_adjust.py entry from howto_faq.rst to test doc-build Modified Paths: -- trunk/matplotlib/doc/faq/howto_faq.rst Modified: trunk/matplotlib/doc/faq/howto_faq.rst === --- trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 20:05:49 UTC (rev 8444) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 20:05:57 UTC (rev 8445) @@ -178,9 +178,6 @@ of each of the labels and uses it to move the left of the subplots over so that the tick labels fit in the figure -.. plot:: pyplots/auto_subplots_adjust.py - :include-source: - .. _howto-ticks: Configure the tick linewidths This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8446] trunk/matplotlib/doc/faq/howto_faq.rst
Revision: 8446 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8446&view=rev Author: leejjoon Date: 2010-06-20 20:55:42 + (Sun, 20 Jun 2010) Log Message: --- remove align_ylabels.py entry from howto_faq.rst to test doc-build Modified Paths: -- trunk/matplotlib/doc/faq/howto_faq.rst Modified: trunk/matplotlib/doc/faq/howto_faq.rst === --- trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 20:05:57 UTC (rev 8445) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 20:55:42 UTC (rev 8446) @@ -218,9 +218,6 @@ below shows the default behavior in the left subplots, and the manual setting in the right subplots. -.. plot:: pyplots/align_ylabels.py - :include-source: - .. _date-index-plots: Skip dates where there is no data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8447] trunk/matplotlib
Revision: 8447
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8447&view=rev
Author: leejjoon
Date: 2010-06-20 23:31:49 + (Sun, 20 Jun 2010)
Log Message:
---
revert r8445,8446 and fix plot_directive.py to support sphinx 1.0
Modified Paths:
--
trunk/matplotlib/doc/faq/howto_faq.rst
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===
--- trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 20:55:42 UTC (rev
8446)
+++ trunk/matplotlib/doc/faq/howto_faq.rst 2010-06-20 23:31:49 UTC (rev
8447)
@@ -178,6 +178,9 @@
of each of the labels and uses it to move the left of the subplots
over so that the tick labels fit in the figure
+.. plot:: pyplots/auto_subplots_adjust.py
+ :include-source:
+
.. _howto-ticks:
Configure the tick linewidths
@@ -218,6 +221,9 @@
below shows the default behavior in the left subplots, and the manual
setting in the right subplots.
+.. plot:: pyplots/align_ylabels.py
+ :include-source:
+
.. _date-index-plots:
Skip dates where there is no data
Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
===
--- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2010-06-20
20:55:42 UTC (rev 8446)
+++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2010-06-20
23:31:49 UTC (rev 8447)
@@ -366,8 +366,13 @@
if options.has_key('include-source'):
if plot_code is None:
+if sphinx_version > (1,):
+include_prefix = '/'
+else:
+include_prefix = setup.app.builder.srcdir
+
lines.extend(
-['.. include:: %s' % os.path.join(setup.app.builder.srcdir,
plot_path),
+['.. include:: %s' % os.path.join(include_prefix, plot_path),
':literal:'])
if options.has_key('encoding'):
lines.append(':encoding: %s' % options['encoding'])
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
