mplfinance
mplfinance copied to clipboard
Feature Request: HLines on AddPlot
Is it possible to implement hlines (and vlines) for addplots. Right now they’re only available on the primary panel.
The vlines functionality might require a bit more thought as it seems more intuitive that the vlines would slice through all the charts vertically. But I suppose an easy work around would just be the draw the same vertical line on the main plot and addplot for now.
duplicate of #140
Hi @luongjames8,
In the mean time, you can easily add hlines to addplots like so:
# Suppose you have DataFrame Column with 'LOGRET'
cumlog_return = df['LOGRET'].cumsum() # cumulative log return
hline0 = [0] * df.shape[0] # You need a hline=0
ap0 = [
mpf.make_addplot(cumlog_return, color='black', panel=2)
mpf.make_addplot(hline0, color='gray', panel=2)
]
mpf.plot(
df, type="candle", volume=True, addplot=ap0,
figscale=1.8, panel_ratios=(7, 2, 2), style='classic',
title=f"\n{ticker}",
)
Hope this helps! KJ
Thanks KJ - will give this a try!
Hi @luongjames8,
In the mean time, you can easily add hlines to addplots like so:
# Suppose you have DataFrame Column with 'LOGRET' cumlog_return = df['LOGRET'].cumsum() # cumulative log return hline0 = [0] * df.shape[0] # You need a hline=0 ap0 = [ mpf.make_addplot(cumlog_return, color='black', panel=2) mpf.make_addplot(hline0, color='gray', panel=2) ] mpf.plot( df, type="candle", volume=True, addplot=ap0, figscale=1.8, panel_ratios=(7, 2, 2), style='classic', title=f"\n{ticker}", )
Hope this helps! KJ
And what about adding vlines on panels? Is there some workaround?