def autolabel(rects, ax, vertical=True):
    """
    Attach labels to a horizontal bar graph
    Input:
    rects <list from ax.barh>
    ax <axis object of plt.subplots>
    Output:
    ax <axis object of plt.subplots> with apt text field to display values on bars is returned
    """
    if vertical:
        for rect in rects:
            height = rect.get_height()
            ax.text(rect.get_x() + rect.get_width() / 2.0, height + 0.01, 
                '%0.2f' % height, ha='center', va='bottom')
    else:
        for i, rect in enumerate(rects):
            width = rect.get_width()
            ax.text(1.05 * width, rect.get_y() + rect.get_height() / 2.0, 
                '%0.2f' % width)
    return ax
