【问题标题】:How to add a simple horizontal line to mplfinance plot? [duplicate]如何在 mplfinance 图中添加一条简单的水平线? [复制]
【发布时间】:2021-07-26 15:34:28
【问题描述】:

我知道这听起来可能太简单了,但它让我陷入了困境! 我有一个使用 fplt 的蜡烛图,我只是想在上面添加一条水平线,但不知道怎么做!

ax = fplt.plot(
                result,
                type='candle',
                style = 'charles',
                title='whatever!',
                ylabel='anything',figsize=(24,8)
            )

这可以很好地创建我想要的蜡烛图! 但后来我使用ax.axhline(...) 但给了我错误,或者我使用ax.plt(x_coordinates,y_coordinates) 但又出现错误: 'NoneType' object has no attribute 'plt'

有人可以让我的生活更轻松吗?!我只想在这里添加一条水平线! 谢谢

【问题讨论】:

  • 作为一般规则,您应该在 SO 问题中说明您为解决问题所做的工作。你没有表明你已经尝试过任何东西。只需在谷歌上搜索“mplfinance 水平线”即可找到答案。

标签: python plot candlestick-chart mplfinance


【解决方案1】:

使用 mplfinance,这就像阅读 mplfinance documentation 一样简单,特别是标题为 Trends, Support, Resistance, and Trading Lines

的部分

你可以看到这就像使用hlines kwarg 一样简单:

另外,mpf.plot()(或者你写得非常规,fplt.plot())返回 None,除非你设置 kwargreturnfig=True,但是对于你想做的,有 没有理由到access the Figure or Axes objects。

第

【讨论】:

    【解决方案2】:

    简要阅读简介https://pypi.org/project/finplot/ 看起来fplt.plot 返回无(然后将其分配给ax),您应该从fplt.create_plot() 获取轴

    【讨论】:

    • 对不起,我不清楚,fplt 是 mplfinance 模块而不是 finplot。出于某种原因,我在安装 finplot 时遇到问题(版本和 dll 文件问题......)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 2023-03-07
    • 2016-03-25
    • 2021-12-15
    • 2016-05-15
    • 2019-08-15
    相关资源
    最近更新 更多