I am updating a real-time candlestick chart project from mpl_finance to mplfinance, and some parts of the code stopped working. For example I am unable to draw horizontal lines once the chart is shown and being updated with new incoming candles.
First I added a listener to mouse movements:
fig.canvas.mpl_connect('motion_notify_event', on_move)
and then implemented the on_move method as follows:
def on_move(event):
if ax is not None:
x, y = ax.transData.inverted().transform([event.x, event.y])
d = num_to_date(x)
if d in df.index:
print(d, y)
# USING MPL_FINANCE THE FOLLOWING WORKS
# hl = plt.axhline(y=y, color='white', linestyle='-', alpha=1)
# plt.draw()
# TRIED THIS FOR THE CURRENT MPLFINANCE BUT NOTHING IS DRAWN
mpf.plot(df, ax=ax, hlines=dict(hlines=[y], colors=['blue'], linestyle='-.', alpha=1))
The console shows the following: console
But the line is not drawn, even if add plt.draw()
: chart
Please help.