def _add_unit(label, xs):
    """Add a unit string to the label if available.

    This also converts a label of density to n_e.

    Parameters
    ----------
    label : str
        The label
    xs : values
        The numeric values

    Returns
    -------
    label : str
        If xs is an AstroPy Quantity then " (<unit>)" is added to the
        label, using LaTeX (inline) formatting. If the input label is
        'density' then it is replaced by '$n_e$'.

    """

    if label == 'density':
        label = '$n_e$'

    try:
        unit = xs.unit.to_string(format='latex_inline')
        return r"{} ({})".format(label, unit)
    except AttributeError:
        return label