def create_scatter_legend(axi, color_labels, class_names, show=False,
                          **kwargs):
    """Generate a legend for a scatter plot with class labels.

    Parameters
    ----------
    axi : object like :class:`matplotlib.axes.Axes`
        The axes we will add the legend for.
    color_labels : dict of objects like :class:`numpy.ndarray`
        Colors for the different classes.
    color_names : dict of strings
        Names for the classes.
    show : boolean, optional
        If True, we will add the legend here.
    kwargs : dict, optional
        Additional arguments passed to the scatter method. Used
        here to get a consistent styling.

    Returns
    -------
    patches : list of objects like :class:`matplotlib.artist.Artist`
        The items we will create a legend for.
    labels : list of strings
        The labels for the legend.

    """
    patches, labels = [], []
    for key, val in color_labels.items():
        patches.append(
            axi.scatter([], [], color=val, **kwargs)
        )
        if class_names is not None:
            label = class_names.get(key, key)
        else:
            label = key
        labels.append(label)
    if show:
        axi.legend(patches, labels, ncol=1)
    return patches, labels