About Matplotlib solution in No module named 'matplotlib.finance' of

Recent research in quantitative analysis, matplotlib need to use a library of input 
from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc
found error, after careful investigation found that there are two problems, one is matplotlib module has been removed, and so you have to install additional in addition Yahoo's data interface at the time of this writing has not been restored
to address the former, there are two methods

 

Method 1:
1. Download mpl_finance module from github, wherein github URL: HTTPS:. //Github.com/matplotlib/mpl_finance
2. By mpl_finance command to install the downloaded modules, namely:
Python setup.py the install

Method 2:
PIP https://github.com/matplotlib/mpl_finance/archive/master.zip the install

 

 

 I use the latter can run, that line of code used to replace

from mpl_finance import candlestick_ohlc
For the latter can tushare interface uses to call 


the following attached a real case, you can take this test if your library installation is complete

 

 

 

# K line drawing implement
Import matplotlib.pyplot AS PLT
Import matplotlib
Import PANDAS AS PD
from mpl_finance Import candlestick_ochl

data = pd.read_hdf("./stock_plot/day_close.h5")[:100]
data1 = pd.read_hdf("./stock_plot/day_close.h5")[:100]
data2 = pd.read_hdf("./stock_plot/day_high.h5")[:100]
data3 = pd.read_hdf("./stock_plot/day_low.h5")[:100]

day = pd.concat([data["000001.SZ"],data1["000001.SZ"], data2["000001.SZ"], data3["000001.SZ"]], axis=1)

day.columns = ["open", "close", "high", "low"]
day = day.reset_index().values


# 画图
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(20,8), dpi=80)

# The first parameter axes
candlestick_ochl (axes, Day, width = 0.3, colorup = "R & lt", colordown = "G")
plt.show ()

Guess you like

Origin www.cnblogs.com/xingnie/p/12219331.html