title: Matplotlib bar charts: Aligning two different y axes to zero
body: <p>I have two sets of data in a barchart which have very different axes: one is very negative (-7500) and one is slightly positive (+5). </p>
  
  <p>How can I have the two y axes aligned at 0, yet still be a good size? Using <code>set_ylim</code> means you can't see the second data set.</p>
  
  <p>Current code I'm using:</p>
  
  <pre><code>A165H = [-4915, -7037]
  B167H = [-6927, -4105]
  B186H = [-5597, 0]
  CH =[0, 0] 
  ConH = [0, 0]
  
  # Lists of dS values
  
  A165S = [6.28,-4.91]
  B167S = [-3.25, 6.7]
  B186S = [3.93, 0]
  CS = [0, 0]
  ConS = [0, 0]
  
  N1H = [A165H[0], B167H[0], B186H[0], CH[0], ConH[0]]
  N1S = [A165S[0], B167S[0], B186S[0], CS[0], ConS[0]]
  print(N1H)
  print(N1S)
  
  N2H = [A165H[1], B167H[1], B186H[1], CH[1], ConH[1]]
  N2S = [A165S[1], B167S[1], B186S[1], CS[1], ConS[1]]
  
  
  width = 0.35
  fig, ax1 = plt.subplots()
  ind = np.arange(len(N1H))
  rects1 = ax1.bar(ind, N1H, width, color = 'b')
  ax1.set_xticks(ind+width)
  ax1.set_xticklabels(('A165', 'B167', 'B186', 'C', 'Con'))
  ax1.set_ylabel('dH', color='b')
  for tl in ax1.get_yticklabels():
      tl.set_color('b')
  
  
  ax2 = ax1.twinx()
  rects2 = ax2.bar(ind + width, N1S, width, color = 'r')
  ax2.set_ylabel('dS', color='r')
  for tl in ax2.get_yticklabels():
     tl.set_color('r')
  
  plt.show()
  </code></pre>
  
  <p>Here is my standard image</p>
  
  <p><a href="https://i.stack.imgur.com/ixd2t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ixd2t.png" alt="enter image description here"></a></p>
  
  <p>EDIT:</p>
  
  <p>using the <code>align_yaxis()</code> from <a href="https://stackoverflow.com/questions/10481990/matplotlib-axis-with-two-scales-shared-origin">this question</a> only shows me the negative values of the second data set:</p>
  
  <p><a href="https://i.stack.imgur.com/dB5jx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dB5jx.png" alt="enter image description here"></a></p>