librosa.display.cmap

librosa.display.cmap(data, use_sns=True, robust=True)[source]

Get a default colormap from the given data.

If the data is boolean, use a black and white colormap.

If the data has both positive and negative values, use a diverging colormap (‘coolwarm’).

Otherwise, use a sequential map: either cubehelix or ‘OrRd’.

Parameters:

data : np.ndarray

Input data

use_sns : bool

If True, and seaborn is installed, use cubehelix maps for sequential data

robust : bool

If True, discard the top and bottom 2% of data when calculating range.

Returns:

cmap : matplotlib.colors.Colormap

  • If data has dtype=boolean, cmap is ‘gray_r’
  • If data has only positive or only negative values, cmap is ‘OrRd’ (use_sns==False) or cubehelix
  • If data has both positive and negatives, cmap is ‘coolwarm’

See also

matplotlib.pyplot.colormaps, seaborn.cubehelix_palette