How do I align gridlines for two y-axis scales using Matplotlib?

前端 未结 7 1587
遇见更好的自我
遇见更好的自我 2020-11-29 00:16

I\'m plotting two datasets with different units on the y-axis. Is there a way to make the ticks and gridlines aligned on both y-axes?

The first image shows what I ge

7条回答
  •  甜味超标
    2020-11-29 00:53

    I had the same issue except this was for a secondary x axis. I solved by setting my secondary x axis equal to the limit of my primary axis.The example below is without setting the limit of the second axis equal to the first:ax2 = ax.twiny()

    Once I set the limit of the second axis equal to the first ax2.set_xlim(ax.get_xlim()) here is my result:

提交回复
热议问题