提问者:小点点

没有名为“matplotlib”的模块。财务”,已弃用,mpl_财务未维护


我需要在图表上绘制一些带有额外线条和各种图形的烛台图表,但我发现matplotlib.finance已被弃用。替换为mpl_finance,但也未维护。

一个诚实的新生Python开发者现在应该用什么来绘制烛台?有什么想法吗?

我将使用的代码如下:

导入matplotlib。pyplot作为plt

from matplotlib.dates import DateFormatter, WeekdayLocator,\
    DayLocator, MONDAY
from matplotlib.finance import candlestick_ohlc

    mondays = WeekdayLocator(MONDAY)
    alldays = DayLocator()              # minor ticks on the days
    weekFormatter = DateFormatter('%b %d')  # e.g., Jan 12
    dayFormatter = DateFormatter('%d')      # e.g., 12

    fig, ax = plt.subplots()
    fig.subplots_adjust(bottom=0.2)
    ax.xaxis.set_major_locator(mondays)
    ax.xaxis.set_minor_locator(alldays)
    ax.xaxis.set_major_formatter(weekFormatter)
    # ax.xaxis.set_minor_formatter(dayFormatter)

    #plot_day_summary(ax, quotes, ticksize=3)
    candlestick_ohlc(ax, candles, width=0.6)

    ax.xaxis_date()
    ax.autoscale_view()
    plt.setp(plt.gca().get_xticklabels(),
             rotation=45, horizontalalignment='right')

共2个答案

匿名用户

您可以不受限制地使用mpl\U finance。它在github上提供。com/matplotlib/mpl_finance。请参阅此处,了解如何安装它。

“未维护”仅仅意味着如果你发现了其中的错误,没有人会为你修复它。

匿名用户

@DonGiulio-它现在得到维护,这里有一个新版本:https://pypi.org/project/mplfinance/