Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing vertical line behind other plots in Matplotlib

I am trying add a vertical line using Matplotlib but I want it to be behind my other plot lines. Currently it overlaps my other lines. Is there a simple way to do this?

plt.axvline(x=date, linestyle=':', color='lightgray')
like image 546
Sanch Avatar asked Oct 18 '25 09:10

Sanch


1 Answers

you should use the parameter zorder

plt.axvline(x=date, linestyle=':', color='lightgray', zorder=0)

your other lines need an higher zorder values

like image 62
Giovanni Frison Avatar answered Oct 20 '25 23:10

Giovanni Frison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!