Python bokeh.palettes() Examples
The following are 3
code examples of bokeh.palettes().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh
, or try the search function
.
Example #1
Source File: state.py From forest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _names_factory(): return list(sorted(bokeh.palettes.all_palettes.keys()))
Example #2
Source File: state.py From forest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _numbers_factory(): return list(sorted(bokeh.palettes.all_palettes["Viridis"].keys()))
Example #3
Source File: plot.py From Pandas-Bokeh with MIT License | 5 votes |
def get_colormap(colormap, N_cols): """Returns a colormap with <N_cols> colors. <colormap> can be either None, a string with the name of a Bokeh color palette or a list/tuple of colors.""" if colormap is None: if N_cols <= 10: colormap = all_palettes["Category10"][10][:N_cols] elif N_cols <= 20: colormap = all_palettes["Category20"][N_cols] else: colormap = all_palettes["Category20"][20] * int(N_cols / 20 + 1) colormap = colormap[:N_cols] elif isinstance(colormap, str): if colormap in all_palettes: colormap = all_palettes[colormap] max_key = max(colormap.keys()) if N_cols <= max_key: colormap = colormap[N_cols] else: colormap = colormap[max_key] colormap = colormap * int(N_cols / len(colormap) + 1) colormap = colormap[:N_cols] else: raise ValueError( f"Could not find <colormap> with name {colormap}. The following predefined colormaps are supported (see also https://bokeh.pydata.org/en/latest/docs/reference/palettes.html ): {list(all_palettes.keys())}" ) elif isinstance(colormap, (list, tuple)): colormap = colormap * int(N_cols / len(colormap) + 1) colormap = colormap[:N_cols] else: raise ValueError( "<colormap> can onyl be None, a name of a colorpalette as string( see https://bokeh.pydata.org/en/latest/docs/reference/palettes.html ) or a list/tuple of colors." ) return colormap