title: How to share secondary y-axis between subplots in matplotlib
body: <p>If you have multiple subplots containing a secondary y-axis (created using <em>twinx</em>), how can you share these secondary y-axis between the subplots? I want them to scale equally in an automatic way (so not setting the y-limits afterwards by hand).
  For the primary y-axis, this is possible by using the keyword <em>sharey</em> in the call of <em>subplot</em>.</p>
  
  <p>Below example shows my attempt, but it fails to share the secondary y-axis of both subplots. I'm using Matplotlib/Pylab:</p>
  
  <pre><code>ax = []
  
  #create upper subplot
  ax.append(subplot(211))
  plot(rand(1) * rand(10),'r')
  
  #create plot on secondary y-axis of upper subplot
  ax.append(ax[0].twinx())
  plot(10*rand(1) * rand(10),'b')
  
  #create lower subplot and share y-axis with primary y-axis of upper subplot
  ax.append(subplot(212, sharey = ax[0]))
  plot(3*rand(1) * rand(10),'g')
  
  #create plot on secondary y-axis of lower subplot
  ax.append(ax[2].twinx())
  #set twinxed axes as the current axes again,
  #but now attempt to share the secondary y-axis
  axes(ax[3], sharey = ax[1])
  plot(10*rand(1) * rand(10),'y')
  </code></pre>
  
  <p>This gets me something like:</p>
  
  <p><img src="https://i.stack.imgur.com/vxw2C.png" alt="Example of two subplots with failed sharing of secondary y-axis"></p>
  
  <p>The reason I used the <em>axes()</em> function to set the shared y-axis is that <em>twinx</em> doesn't accept the <em>sharey</em> keyword.</p>
  
  <p>I'am using Python 3.2 on Win7 x64. Matplotlib version is 1.2.0rc2.</p>