def _get_index_and_colors(values, objects, predicate, color_mapper):
    """
    Get index and RGB colors from a color map using a rule.

    The predicate acts on a tuple of (value, object).

    Arguments:
        values (Iterable): floats representing a color.
        objects (Iterable): objects associated to the colors.
        predicate (Callable): a predicate to filter objects.
        color_mapper (cm.ScalarMappable): a mapper from floats to RGBA.

    Returns:
        Iterables of indices and RGBA colors.
    """
    indices = []
    colors = {}
    for index, value in enumerate(
        map(
            lambda t: t[0],
            filter(
                lambda t: predicate(t),
                zip(values, objects)
            )
        )
    ):
        indices.append(index)
        colors[index] = color_mapper.to_rgba(value)
    return indices, colors