Since matplotlib.finance is deprecated, how can I use the new mpl_finance module?

I am trying to import the matplotlib.finance module in python so that I can plot the OCHL Candlestick. My version of matplotlib.pyplot is 2.00. I 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 financial module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the mpl_finance module 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 a candlestick from matplotlib.pyplot ?

+15
source share
6 answers

This warning tells you that the financial module will be removed at some point.

You do not need to worry about this warning at this time. This will affect you only when you upgrade to version 2.2 of matplotlib, in which case you will have to change your import.

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

After downloading the files, you can install in the usual way,

 python setup.py install 

Alternatively, you can try installing via pip,

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

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

+15
source

Since mpl_finace is no longer included in pip, you can also use the following command to install mpl_finance on pip :

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

+25
source

In 2019, you can now pip install mpl_finance

+4
source

mpl_finance no longer part of matplotlib . Install the module directly from gitHub via pip

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

and import it with

 from mpl_finance import candlestick_ohlc 

Then it works the same as before.

+3
source

Plotly.py , an interactive web-based charting module, has financial charting functions https://plot.ly/python/candlestick-charts/ . And it is supported.

0
source

I am working on Google Colab, I have the same problem. then what i did -for python3.6

import mpl_finance

from mpl_finance import candlestick_ohlc

0
source

Source: https://habr.com/ru/post/1264530/


All Articles