gammapy.image.grayify_colormap(cmap, mode='hsp')[source]

Return a grayscale version a the colormap.

The grayscale conversion of the colormap is bases on perceived luminance of the colors. For the conversion either the rgb2gray or a generic method called hsp [R2] can be used. The code is loosely based on [R3].


cmap : str or Colormap

Colormap name or instance.

mode : {‘skimage, ‘hsp’}

Grayscale conversion method. Either skimage or hsp.


[R2](1, 2) Darel Rex Finley, “HSP Color Model - Alternative to HSV (HSB) and HSL”
[R3](1, 2) Jake VanderPlas, “How Bad Is Your Colormap?”