Force pyplot subplots to use the same y-axis scale
<p>I have a script to plot count rates with the raw source data, background and source with background corrected that I would like to display one below the other. However, I would also like the three separate subplots to have the same y-axis limits and scale in order to aid comparison of the three. Since I will be applying it to numerous datasets, I can't really just set all three to have the same limits manually each time.</p>

<p>Here's a MWE: </p>

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

x = np.arange(11)
y1 = np.arange(1,6.1,0.5)
y2 = np.arange(11)
y3 = np.arange(4,9.1,0.5)

plt.subplot(3,1,1)
plt.errorbar(x, y1, yerr=0.5)

plt.subplot(3,1,2)
plt.errorbar(x, y2, yerr=1.0)

plt.subplot(3,1,3)
plt.errorbar(x, y3, yerr=0.5)

plt.show()
</code></pre>