Matplotlib/Pyplot: How to zoom subplots together?
The easiest way to do this is by using the sharex
and/or sharey
keywords when creating the axes:
from matplotlib import pyplot as plt
ax1 = plt.subplot(2,1,1)
ax1.plot(...)
ax2 = plt.subplot(2,1,2, sharex=ax1)
ax2.plot(...)
You can also do this with plt.subplots
, if that's your style.
fig, ax = plt.subplots(3, 1, sharex=True, sharey=True)