Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

python 3.x - Since matplotlib.finance has been deprecated, how can I use the new mpl_finance module?

I am trying to import matplotlib.finance module in python so that I can make a Candlestick OCHL graph. My matplotlib.pyplot version is 2.00. I've tried to import it using the following commands:

import matplotlib.finance
from matplotlib.finance import candlestick_ohlc

I get this error:

warnings.warn(message, mplDeprecation, stacklevel=1) MatplotlibDeprecationWarning: The finance module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the module mpl_finance instead.

Then instead of using the above lines in python I tried using the following line:

import mpl_finance

I get this error:

ImportError: No module named 'mpl_finance'

What should I do to import candlestick from matplotlib.pyplot?

question from:https://stackoverflow.com/questions/42373104/since-matplotlib-finance-has-been-deprecated-how-can-i-use-the-new-mpl-finance

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What this warning tells you is that the finance module will be removed at some point.

At the moment you don't need to worry about this warning. It will only affect you when you update to a yet to be released version 2.2 of matplotlib, in which case you'll need to change your imports.

If you already want to be compatible with future versions now, you can download the mpl_finance module from https://github.com/matplotlib/mpl_finance .

After having downloaded the files, you may install in the usual way,

python setup.py install

Alternatively you may try installing through pip,

pip install https://github.com/matplotlib/mpl_finance/archive/master.zip

The reason for this is that the people at matplotlib want to keep their code clean and not maintain a specialized sidepackage like this in the main code. They probably also do not want to maintain the package and spend resources on it, which can be better used in the core development.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...