def autolabel(rects):
    """
    Attach a text label above each bar displaying its height
    """
for rect in rects:
    height = rect.get_height()
ax.text(rect.get_x() + rect.get_width() / 2.0, 1.05 * height, '%d' % int(
    height), ha='center', va='bottom')
autolabel(rects1)
autolabel(rects2)
plt.show()
How to display the value of the bar on each bar with pyplot.barh()?