I have subplots whose ylims I want to keep locked, so I can scroll through them using matplotlib's UI. I just want to pan through in the x direction, but sometimes I accidentally pan up/down so that the data pans off screen. Here is an example of an oops:
What can I do so this doesn't happen? I set the ylims programmatically, and that sets them up fine initially , but doesn't stop me from panning accidentally:
xvals = np.arange(0,1000,0.1)
yvals1 = np.sin(3*xvals)
yvals2 = yvals1 + 30
f, (ax1, ax2) = plt.subplots(2,1,sharex = True);
ax1.plot(xvals, yvals1)
ax1.set_xlim(2,5)
ax1.set_ylim(-1.3,1.3)
ax2.plot(xvals, yvals2);
Is there a way to lock those ylims in place so I can't pan the data off the axes?