如何使用MPLS为y轴中的hline增值

2024-09-28 18:54:11 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

这就是我的情节 candlestick + hlines


Tags: 模块绘图密码plot图表绘制dictclusters
1条回答
网友
1楼 · 发布于 2024-09-28 18:54:11

尝试以下操作:设置returnfig=True以获得access to the Figure and Axes objects,然后使用matplotlib的^{}^{}标记hline:

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()

相关问题 更多 >