2

Hello everyone and thank you for your help in advance. I have managed to plot a candlestick chart using mplfinance module in python and I have added some hlines to my plot. The problem is, I can't figure out how to add hlines value to yaxis of my chart.

here is my code: mpf.plot(hloc,hlines=dict(hlines=clusters_centers,colors=['blue'],linestyle='-.'), ylabel='Price', type='candle', style='binance')

and this is how my plot looks like candlestick + hlines

Ali Moayed
  • 33
  • 5

1 Answers1

1

Try the following: Set returnfig=True to gain access to the Figure and Axes objects, then use matplotlib's Axes.text() or Axes.annotate() to label your hlines:

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()
Daniel Goldfarb
  • 6,937
  • 5
  • 29
  • 61