Skip to content

Commit 335536c

Browse files
committed
Merge pull request scikit-learn#5919 from nelson-liu/fix_stock_example
[MRG+2] Fixed plot_stock_market.py example to work with matplotlib 1.4.x+
2 parents b59b0e1 + 48ad7aa commit 335536c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/applications/plot_stock_market.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@
6868

6969
import numpy as np
7070
import matplotlib.pyplot as plt
71-
from matplotlib import finance
71+
try:
72+
from matplotlib.finance import quotes_historical_yahoo_ochl
73+
except ImportError:
74+
# quotes_historical_yahoo_ochl was named quotes_historical_yahoo before matplotlib 1.4
75+
from matplotlib.finance import quotes_historical_yahoo as quotes_historical_yahoo_ochl
7276
from matplotlib.collections import LineCollection
73-
7477
from sklearn import cluster, covariance, manifold
7578

7679
###############################################################################
@@ -146,7 +149,7 @@
146149

147150
symbols, names = np.array(list(symbol_dict.items())).T
148151

149-
quotes = [finance.quotes_historical_yahoo(symbol, d1, d2, asobject=True)
152+
quotes = [quotes_historical_yahoo_ochl(symbol, d1, d2, asobject=True)
150153
for symbol in symbols]
151154

152155
open = np.array([q.open for q in quotes]).astype(np.float)

0 commit comments

Comments
 (0)