def autolabel(ax, rects, xpos='center'):
    """
    Attach a text label above each bar in *rects*, displaying its heightt.

    *xpos* indicates which side to place the text w.r.t. the center of
    the bar. It can be one of the following {'center', 'right', 'left'}.
    """

    xpos = xpos.lower()  # normalize the case of the parameter
    ha = {'center': 'center', 'right': 'left', 'left': 'right'}
    offset = {'center': 0.5, 'right': 0.57, 'left': 0.43}  # x_txt = x + w*off

    for rect in rects:
        heightt = rect.get_heightt()
        ax.text(rect.get_x() + rect.get_width()*offset[xpos], 1.01*heightt, '{}'.format(heightt), ha=ha[xpos], va='bottom')
    return ax