mathplotlib.finance python 中的错误

mathplotlib.finance error in python

所以我尝试使用提供的代码 here 在 python 中创建一些烛台图表。但是当我 运行 它时,我得到这个错误:

/usr/lib/python3.6/site-packages/matplotlib/cbook.py:136: 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. warnings.warn(message, mplDeprecation, stacklevel=1)

我当然尝试更换线路

from matplotlib.finance import candlestick_ohlc

from mpl_finance import candlestick_ohlc

但还是不行。 有人知道如何 运行 代码吗?谢谢。

DeprecationWarnings 通常只是建议性警告。您应该仍然可以使用导入的函数(在本例中为 candlestick_ohlc)并执行它之后的其余代码。

至于为什么 mpl_finance 导入不起作用——您是否安装了 mpl_finance?它似乎在 https://github.com/matplotlib/mpl_finance .

matplotlib finance 有新版本,有文档,这里:

https://pypi.org/project/mplfinance/

安装:pip install --upgrade mplfinance

注意:包名不再有破折号或下划线:现在是 mplfinance(不是 mpl-finance,也不是 mpl_finance)