neuralib.plot.colormap.DiscreteColorMapper
- class neuralib.plot.colormap.DiscreteColorMapper[source]
Bases:
objectmap 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]