既不维护不推荐使用的名为'matplotlib.finance'的模块,也不维护mpl_finance

时间:2018-11-04 10:34:16

标签: python matplotlib

我需要绘制一些烛台图表,图表上带有其他线条和各种图形,但是我发现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 个答案:

答案 0 :(得分:0)

您可以不受限制地使用mpl_finance。它在github.com/matplotlib/mpl_finance上可用。有关如何安装的信息,请参见here

“未维护”仅表示如果您发现其中的错误,没有人会为您修复。

答案 1 :(得分:0)

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