code: def _annotate(ax, annotate, height, left, width):
      
      annotate_yrange_factor = 0.010
      xticks = np.array(left) + width / 2.0
      ymin, ymax = ax.get_ylim()
      yrange = ymax - ymin
  
      # Reset ymax and ymin so there's enough room to see the annotation of
      # the top-most
      if ymax > 0:
          ymax += yrange * 0.15
      if ymin < 0:
          ymin -= yrange * 0.15
      ax.set_ylim(ymin, ymax)
      yrange = ymax - ymin
  
      offset_ = yrange * annotate_yrange_factor
      if isinstance(annotate, collections.Iterable):
          annotations = map(str, annotate)
      else:
          annotations = ['%.3f' % h if type(h) is np.float_ else str(h)
                         for h in height]
      for x, h, annotation in zip(xticks, height, annotations):
          # Adjust the offset to account for negative bars
          offset = offset_ if h >= 0 else -1 * offset_
          verticalalignment = 'bottom' if h >= 0 else 'top'
  
          if len(str(annotation)) > 6:
              size = 7
          elif len(str(annotation)) > 5:
              size = 8
          else:
              size = 10
          # Finally, add the text to the axes
          ax.annotate(annotation, (x, h + offset),
                      verticalalignment=verticalalignment,
                      horizontalalignment='center',
                      size=size)
docs: Annotate axis with labels.