neuralib.plot.colormap.DiscreteColorMapper

class neuralib.plot.colormap.DiscreteColorMapper[source]

Bases: object

map color to iterable object

Example of a ``dict`` palette

>>> palette = {3: ('#3182bd', '#6baed6', '#9ecae1'),
...            5: ('#a1d99b', '#c7e9c0', '#756bb1', '#9e9ac8', '#bcbddc')}
>>> cmapper = DiscreteColorMapper(palette, 5)
>>> x = ['1', '2', '3']
>>> color_list = [cmapper[i] for i in x]

Example of a mpl ``str`` palette

>>> cmapper = DiscreteColorMapper('viridis', 20)
>>> regions = ['rsc', 'vis', 'hpc']
>>> color_list = [cmapper[r] for r in regions]
__init__(palette, number)[source]
Parameters:
  • palette (dict[int, tuple[str, ...]] | str) – A custom dictionary color palette or a Matplotlib colormap name

  • number (int) – Number of colors to cycle through in the palette or colormap

Methods

__init__(palette, number)

__init__(palette, number)[source]
Parameters:
  • palette (dict[int, tuple[str, ...]] | str) – A custom dictionary color palette or a Matplotlib colormap name

  • number (int) – Number of colors to cycle through in the palette or colormap