def __truncate_text__(ax, text, renderer, st, en, textkwargs):
    """Truncate the text to fit nicely in the plot

    Recursively cuts 10 % of the text until the text fits
    (horizontally) in an area defined in plotted units

    ax -- the matplotlib Axes object of a subplot
    text -- the text to fit in the area
    renderer -- the figure.canvas.renderer object
    st, en -- the left-to-right limits of the area (in
              plotted units)

    textkwargs -- the fontdict of the text

    """
    mytext = ax.text(st, 0.5, text, alpha=0, **textkwargs)
    width = mytext.get_window_extent(renderer).width
    start = ax.transData.transform([st, 0])[0]
    end = ax.transData.transform([en, 0])[0]
    while width > (end - start):
        mytext = ax.text(st, 0.5, text, alpha=0, **textkwargs)
        width = mytext.get_window_extent(renderer).width
        start = ax.transData.transform([st, 0])[0]
        end = ax.transData.transform([en, 0])[0]
        text = text[:int(0.9 * len(text))]
    return text