cmap2rgba

typhon.plots.cmap2rgba(cmap=None, N=None, interpolate=True)[source]

Convert a colormap into a list of RGBA values.

Parameters:
  • cmap (str) – Name of a registered colormap.

  • N (int) – Number of RGBA-values to return. If None use the number of colors defined in the colormap.

  • interpolate (bool) – Toggle the interpolation of values in the colormap. If False, only values from the colormap are used. This may lead to the re-use of a color, if the colormap provides less colors than requested. If True, a lookup table is used to interpolate colors (default is True).

Returns:

RGBA-values.

Return type:

ndarray

Examples

>>> cmap2rgba('viridis', 5)
array([[ 0.267004,  0.004874,  0.329415,  1.      ],
    [ 0.229739,  0.322361,  0.545706,  1.      ],
    [ 0.127568,  0.566949,  0.550556,  1.      ],
    [ 0.369214,  0.788888,  0.382914,  1.      ],
    [ 0.993248,  0.906157,  0.143936,  1.      ]])