title: Pandas, Bar Chart Annotations
body: <p><strong>How to properly give Annotations to Pandas Bar Charts?</strong></p>
  
  <p>I'm following <a href="http://robertmitchellv.com/blog/bar-chart-annotations-with-pandas-and-mpl.html" rel="nofollow noreferrer">Bar Chart Annotations with Pandas and MPL</a>, but somehow I can't make it into my own code -- <a href="https://gist.github.com/suntong/d09ef3400756a73af73d" rel="nofollow noreferrer">this is as far as I can go</a>. What's wrong? </p>
  
  <p>I've also found the following code <a href="http://matplotlib.org/examples/api/barchart_demo.html" rel="nofollow noreferrer">from here</a>:</p>
  
  <pre><code>def autolabel(rects):
      # attach some text labels
      for rect in rects:
          height = rect.get_height()
          ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
                  '%d' % int(height),
                  ha='center', va='bottom')
  
  autolabel(rects1)
  autolabel(rects2)
  </code></pre>
  
  <p>But I don't how to apply that to my code either. Please help. </p>
  
  <p>UPDATE: </p>
  
  <p>Thank you @CT Zhu, for the answer. However, in your horizontal bars, you are still placing the text on top of bars, but I need the text show up within or along them, like this from my referenced article,</p>
  
  <p><a href="https://i.stack.imgur.com/ePCIM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ePCIM.png" alt="enter image description here"></a></p>
  
  <p>where s/he says, </p>
  
  <blockquote>
    <p>"I am very parital to horizontal bar charts, as I really think they are easier to read, however, I understand that a lot of people would rather see this chart implemented in a regular bar chart. So, here is the code to do that; you will notice that a few things have changed in order to create the annotation"*</p>
  </blockquote>