def add_top_title(ax, title, **kwargs):
    """Add a centered title on top of the selected axis.

    All :func:`~matplotlib.Axes.annotate` parameters are
    accessible.

    :param ax: Target plot axis.
    :type ax: :py:class:`~matplotlib.Axes`
    :param str title: Title text to add.

    :return: :class:`~matplotlib.text.Annotation`
    """
    if title is None:
        return
    kwargs.setdefault('xy', (0.5, 1))
    kwargs.setdefault('xytext', (0, 5))
    kwargs.setdefault('xycoords', 'axes fraction')
    kwargs.setdefault('textcoords', 'offset points')
    kwargs.setdefault('ha', 'center')
    kwargs.setdefault('va', 'baseline')
    return ax.annotate(title, **kwargs)
