Matplotlib: draws grid lines behind other elements of the chart , but nothing worked for me.
I have the following graph where I want to hide the grid lines under the red line, keeping the labels above the red line:
import numpy as np import matplotlib.pyplot as plt

I can get the red line on top of ax.set_axisbelow(True) .

But I canβt find a way to keep the red line on top of the grid lines, keeping the labels on top of the red line. When adding zorder=-1 to the plot command, put the red line at the bottom, even if I add ax.set_axisbelow(True) . ax.set_zorder(-1)) does not work yet.
How can I get the grid lines at the bottom (the lowest zorder), followed by the red line, and then the labels above the red line?
python matplotlib z-order gridlines
Joel Ostblom Apr 08 '15 at 18:22 2015-04-08 18:22
source share