def _title(fig, title, subtitle="", *, margin=1, fontsize=20, subfontsize=18):
    """Add a title to a figure.

    Parameters
    ----------
    fig : matplotlib Figure
        Figure.
    title : string
        Title.
    subtitle : string
        Subtitle.
    margin : number (optional)
        Distance from top of plot, in inches. Default is 1.
    fontsize : number (optional)
        Title fontsize. Default is 20.
    subfontsize : number (optional)
        Subtitle fontsize. Default is 18.
    """
    fig.suptitle(title, fontsize=fontsize)
    height = fig.get_figheight()  # inches
    distance = margin / 2.  # distance from top of plot, in inches
    ratio = 1 - distance / height
    fig.text(0.5, ratio, subtitle, fontsize=subfontsize, ha="center", va="top")