我在两个不同的轴上绘制了一个柱状图和一个折线图。我希望条形图出现在折线图的后面。
fig, ax1 = plt.subplots() # ax1 is line graph, ylabel on the left
ax2 = ax1.twinx() # ax2 is bar graph, ylabel on the right如果我按此顺序设置轴,条形图将显示在顶部。但是,如果我交换它们,那么y标签的位置也会交换。如何使条形图出现在折线图的后面,同时保持y标签的位置不变?
发布于 2020-08-14 04:50:53
在这里找到了解决方案:PyPlot move alternative y axis to background
解决方案是将ax1 zorder设置为高于ax2,并禁用ax1背景。
https://stackoverflow.com/questions/63402842
复制相似问题