Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: HLines on AddPlot #204

Open
luongjames8 opened this issue Jul 2, 2020 · 4 comments
Open

Feature Request: HLines on AddPlot #204

luongjames8 opened this issue Jul 2, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@luongjames8
Copy link

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.

@luongjames8 luongjames8 added the enhancement New feature or request label Jul 2, 2020
@DanielGoldfarb
Copy link
Collaborator

duplicate of #140

@twopirllc
Copy link

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

@luongjames8
Copy link
Author

Thanks KJ - will give this a try!

@k1mbl3
Copy link

k1mbl3 commented Dec 4, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants