0

I have a plot with a bar graph and a line graph on two separate axes. I want the bar graph to appear behind the line graph.

    fig, ax1 = plt.subplots() # ax1 is line graph, ylabel on the left
    ax2 = ax1.twinx() # ax2 is bar graph, ylabel on the right

If I set the axes in this order, the bar graph appears on top. However if I swap them, then the y label positions swap as well. How can I make the bar graph appear behind the line graph, while keeping the positions of the y labels in place?

xyzhou
  • 39
  • 1
  • 7

1 Answers1

0

Found the solution here: PyPlot move alternative y axis to background

The solution is to set the ax1 zorder higher than ax2 and disable the ax1 background.

xyzhou
  • 39
  • 1
  • 7