mplfinance icon indicating copy to clipboard operation
mplfinance copied to clipboard

zorder of plots (scatter - line) added with addplot

Open JessicaG11 opened this issue 4 years ago • 4 comments

Is there a way to manage the order (z axis) of the graphs added with addplot? Currently I would like to display my scatter on top of my line, but no matter what order I pass them in addplot the line appears on top. With matplotlib there is zorder which manages this.

Here is a small exemple of code for which the line_plot appears over the scatter_plot: scatter_plot = mpf.make_addplot(scatter_data, type='scatter') line_plot = mpf.make_addplot(line_data, type='line') mpf.plot(candle_data, type='candle', addplot=[scatter_plot, line_plot])

Thank you very much!

JessicaG11 avatar Jan 08 '21 15:01 JessicaG11

Jessica,

Good point! I think we should add a zorder kwarg to both mpf.plot() (for the candles, etc.) and mpf.make_addplot(). Candles may be tricky because they are made up of both line collections and patch colletions which by default have different zorders; however adding zorder to make_addplot() should be relatively trivial. Are you interested in making the change?

Thanks. --Daniel

DanielGoldfarb avatar Jan 08 '21 16:01 DanielGoldfarb

I did a little playing around with the code. Even the candlesticks will be easy to set the zorder.

DanielGoldfarb avatar Jan 08 '21 20:01 DanielGoldfarb

Hi, is there any solution for that? i have the same problem, can REALLY use zOrder in my subplots

Omri93h avatar Mar 18 '21 15:03 Omri93h

@Omri93h Omri, I am hoping to have time to implement a zorder kwarg for plot() and for make_addplot() sometime in the next 6 to 8 weeks. If you would like to contribute this enhancement to mplfinance, I would be happy to guide you through the process; just let me know. All the best. --Daniel

DanielGoldfarb avatar Mar 18 '21 15:03 DanielGoldfarb