Skip to content

multiple line(style,color,width) in make_addplot() #690

New issue

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

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

Already on GitHub? # to your account

Open
vinaychuri opened this issue Feb 24, 2025 · 1 comment
Open

multiple line(style,color,width) in make_addplot() #690

vinaychuri opened this issue Feb 24, 2025 · 1 comment
Labels
question Further information is requested

Comments

@vinaychuri
Copy link

"https://github.com/matplotlib/mplfinance/blob/master/examples/addplot.ipynb" mentions about adding multiple columns to make_addplot() via a dataframe.
Ex: adding multiple lines for the (bbands,ADX,macd)

But the make_addplot() does not accept list of values for the linecolor,style,width etc.
Interestingly, the label keyword accepts list of lables

Since the function does accept multiple datasets, is it possible to color/style the lines in the same function call?
Ex:
mpl.make_addplot(
plot_df[["A","B" ,"C"]],
linestyle=["dashdot","dashed","dotted"],
width=[0.5,1,1.5],
panel=1,
color=["blue","green","black"],
label=["A","_" ,"C"],
)

@vinaychuri vinaychuri added the question Further information is requested label Feb 24, 2025
@DanielGoldfarb
Copy link
Collaborator

You should call make_addplot() three times and put the results in a list.

Something like this:

add_plots = [
    mpf.make_addplot(plot_df[["A"]],linestyle="dashdot",width=0.5,panel=1,color="blue",label="A") ,
    mpf.make_addplot(plot_df[["B"]],linestyle="dashed",width=1,panel=1,color="green",label="_") ,
    mpf.make_addplot(plot_df[["C"]],linestyle="dotted",width=1.5,panel=1,color="black",label="C") ,
]

mpf.plot(data, addplot=add_plots)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants