matplotlib / mplfinance

Financial Markets Data Visualization using Matplotlib
https://pypi.org/project/mplfinance/
Other
3.59k stars 621 forks source link

zorder of plots (scatter - line) added with addplot #311

Open JessicaG11 opened 3 years ago

JessicaG11 commented 3 years ago

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!

DanielGoldfarb commented 3 years ago

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 commented 3 years ago

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

Omri93h commented 3 years ago

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

DanielGoldfarb commented 3 years ago

@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