def add_matplotlib_cmaps(fail_on_import_error=True):
    """Add all matplotlib colormaps."""
    try:
        from matplotlib import cm as _cm
        from matplotlib.cbook import mplDeprecation
    except ImportError:
        if fail_on_import_error:
            raise
        # silently fail
        return

    for name in _cm.cmap_d:
        if not isinstance(name, str):
            continue
        try:
            # Do not load deprecated colormaps
            with warnings.catch_warnings():
                warnings.simplefilter('error', mplDeprecation)
                cm = _cm.get_cmap(name)
                add_matplotlib_cmap(cm, name=name)
        except Exception as e:
            if fail_on_import_error:
                print("Error adding colormap '%s': %s" % (name, str(e)))
Add all matplotlib colormaps.