mplfinance
mplfinance copied to clipboard
How can I specify different colors for make_addplot?
Well...the question is in the title. I want to specify the color to use on each indicator in the make_addplot. Is this possible in one line or I need to break it in multiple lines?
Is mpf.make_addplot(bars[["sma_10","sma_200"]],color=["red","blue"],ax=ax1)
possible? Asking because I'm getting an error if I do this.
I don't believe there is a way to make one addplot call have two colors.
What you can do is create a list of multiple addplot calls, each with ito's own color specification.
apds = [mpf.make_addplot(bars[['sma_10']],color='red'),
mpf.make_addplot(bars[['sma_200']],color='blue')]
then for the addplot argument in mpf.plot() you specify the list of apds.
mpf.plot(bars[['o','h','l','c']], addplot=apds)
This answer is correct.
It is possible that make_addplot()
could be modified to accept a list of tuple of colors, but this list or tuple may need to be treated differently for scatter plots versus line plots. This enhancement can be done if there is enough demand for it (or if you want to do the work).