def __get_renderer(axes):
    """Retrieve appropriate renderer.

    :param axes: matplotlib axes for which we want the renderer
    :type axes: matplotlib.axes.Axes
    """
    if hasattr(axes.get_figure().canvas, 'get_renderer'):
        renderer = axes.get_figure().canvas.get_renderer()
    else:
        import io
        axes.get_figure().canvas.print_pdf(io.BytesIO())
        renderer = axes.get_figure()._cachedRenderer
    return renderer
