In Python Spyder interactive plotting. How do I link plots so that when I zoom in on a plot it zooms in on the rest
<p>In Python Spyder interactive plotting. How do I link plots so that when I zoom in on one plot in one figure, it zooms all the other plots that are on the same figure and different figure to the same scale? They are all plotted vs time which is mSec.</p>

<p>Here is a sample of my current code that is still in the works. (I know I am plotting the same thing twice, I am just testing few things.)</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt


data = np.loadtxt('data'.csv', delimiter=',', skiprows=1)


# This uses array slicing/indexing to cut the correct columns into variables.
mSec = data[:,0]
Airspeed = data[:,10]
AS_Cmd = data[:,25]
airspeed = data[:,3]

plt.rc('xtick', labelsize=15) #increase xaxis tick size
plt.rc('ytick', labelsize=15) #increase yaxis tick size

# Create a figure figsize = ()
fig1 = plt.figure(figsize= (20,20))
ax = fig1.add_subplot(211)

ax.plot(mSec, Airspeed, label='Ground speed [m/s]', color = 'r')
ax.plot(mSec, AS_Cmd, label='AS_Cmd')
plt.legend(loc='best',prop={'size':13})
ax.set_ylim([-10,40])

ax1 = fig1.add_subplot(212)

ax1.plot(mSec, Airspeed, label='Ground speed [m/s]', color = 'r')
ax1.plot(mSec, AS_Cmd, label='AS_Cmd[m/s]')
# Show the legend
plt.legend(loc='lower left',prop={'size':8})
fig1.savefig('trans2.png', dpi=(200), bbox_inches='tight') #borderless on save
</code></pre>

<p><code>sharex</code> and <code>sharey</code> are your friends.
Minimal example:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

fig1, (ax1, ax2) = plt.subplots(1,2,sharex=True, sharey=True)
ax1.plot(np.random.rand(10))
ax2.plot(np.random.rand(11))

fig2 = plt.figure()
ax3 = fig2.add_axes([0.1, 0.1, 0.8, 0.8], sharex=ax1, sharey=ax1)
ax3.plot(np.random.rand(12))
</code></pre>

python matplotlib spyder