neuralib.plot.colormap
- class neuralib.plot.colormap.DiscreteColorMapper[source]
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]
- neuralib.plot.colormap.get_customized_cmap(name, value, numbers, endpoint=True)[source]
Generate gradient color map array. N = number of color
- Parameters:
name (str) – name of cmap
value (tuple[float, float]) – value range, could be 0-1
numbers (int) – N
endpoint (bool) – If cyclic colormap, then used False
- Returns:
RGBA. Array[float, [N, 4]]
- Return type:
ndarray
- neuralib.plot.colormap.insert_colorbar(ax, im, **kwargs)[source]
Insert colormap
- Parameters:
ax (Axes) –
Axesim (_ScalarMappable) –
ScalarMappablekwargs – Additional args pass to
ax.figure.colorbar
- Returns:
- Return type:
Colorbar
- neuralib.plot.colormap.insert_cyclic_colorbar(ax, im, *, num_colors=12, num_labels=4, width=0.6, inner_diameter=0.6, vmin=None, vmax=None)[source]
Insert cyclic colormap in
inset_axes- Parameters:
ax (Axes) –
Axesim (_ScalarMappable) –
ScalarMappablenum_colors (int) – Number of color in the cyclic colorbar
num_labels (int) – Number of labels in the cyclic colorbar
width (float) – Width of the each color
inner_diameter (float) – The size of the inner circle
vmin (float | None) – Min value of the colormap, equal to
vmaxin cyclic datavmax (float | None) – Max value of the colormap, equal to
vminin cyclic data
- Return type:
None