title: matplotlib: Aligning twin y-axes
body: <p><a href="https://stackoverflow.com/questions/21944139/trouble-with-aligning-two-y-axis-ticks-with-matplotlib">The answer to this question</a> suggests that I play around with the <code>set_ylim</code>/<code>get_ylim</code> in order to align two twin axes. However, this does not seem to be working out for me.</p>
  
  <p>Code snippet:</p>
  
  <pre><code>fig, ax1 = plt.subplots()
  
  yLim = [minY, maxY]
  xLim = [0, 0.01]
  
  for x in analysisNumbers:
      ax1.plot(getData(x), vCoords, **getStyle(x))
  
  ax1.set_yticks(vCoords)
  ax1.grid(True, which='major')
  
  
  ax2 = ax1.twinx()
  ax2.set_yticks(ax1.get_yticks())
  ax2.set_ylim(ax1.get_ylim())
  ax2.set_ylim(ax1.get_ylim())
  
  plt.xlim(xLim[0], xLim[1])
  plt.ylim(yLim[0], yLim[1])
  
  plt.minorticks_on()
  
  plt.show()
  </code></pre>
  
  <p>Graph output (open image in a new window):</p>
  
  <p><img src="https://i.stack.imgur.com/XaORu.png" alt="enter image description here"></p>
  
  <p>The twin axes should be the same, but they are not. Their labels are the same, but their alignment is not (see that the zeroes do not line up). What's wrong?</p>