We can set the grid based on the right y-axis with matlab:
https://www.mathworks.com/matlabcentral/answers/671503-how-to-set-the-grid-of-the-right-yyaxis
You see that the horizontal gridlines based on the right y-axis ,instead of the left y-axis.In matplotlib,ax.grid(axis = "y") draw the horizontal gridlines based on the left y-axis.
ax.grid(axis = "y")
How can do it with matplotlib then?
>Solution :
As you have two y-axis, you can set the secondary axis grid to true using ax2.grid(). Working example…
fig, ax=plt.subplots(figsize=(7,7))
ax1=ax.twinx()
ax1.set_ylim(-1,3)
ax1.grid()
ax.xaxis.grid(True)
plt.show()

