【问题标题】:How to add value of hlines in y axis using mplfinance python如何使用 mplfinance python 在 y 轴上添加 hlines 的值
【发布时间】:2021-08-09 13:12:09
【问题描述】:

大家好,提前感谢您的帮助。我已经设法在 python 中使用 mplfinance 模块绘制了一个烛台图,并且我在我的图中添加了一些 hlines。问题是,我不知道如何将 hlines 值添加到图表的 y 轴。

这是我的代码: mpf.plot(hloc,hlines=dict(hlines=clusters_centers,colors=['blue'],linestyle='-.'), ylabel='Price', type='candle', style='binance')

这就是我的情节的样子 candlestick + hlines

【问题讨论】:

    标签: python candlestick-chart mplfinance


    【解决方案1】:

    尝试以下操作:将returnfig=True 设置为获得access to the Figure and Axes objects,然后使用matplotlib 的Axes.text()Axes.annotate() 标记您的线:

    hlines=dict(hlines=clusters_centers,colors=['blue'],linestyle='-.')
    
    fig, axlist = mpf.plot(hloc,hlines=hlines,
                           ylabel='Price',type='candle', 
                           style='binance',returnfig=True)
    
    x = len(hloc)
    for y in cluster_centers:
        axlist[0].annotate(str(y),(x,y))
    
    mpf.show()
    

    【讨论】:

    • 非常感谢。这正是我想要的
    猜你喜欢
    • 1970-01-01
    • 2018-08-17
    • 2020-08-04
    • 2014-02-19
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    • 2016-12-19
    • 1970-01-01
    相关资源
    最近更新 更多