def autolabel(rects, axis):
    """Attach a text label above each bar in *rects*, displaying its height."""
    for rect in rects:
        height = rect.get_height()
        axis.annotate('{}'.format(height), xy=(rect.get_x() + rect.
            get_width() / 2, height), xytext=(0, 2), textcoords=
            'offset points', ha='center', va='bottom')
