本文整理汇总了Python中bokeh.palettes方法的典型用法代码示例。如果您正苦于以下问题:Python bokeh.palettes方法的具体用法?Python bokeh.palettes怎么用?Python bokeh.palettes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh
的用法示例。
在下文中一共展示了bokeh.palettes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_colormap
# 需要导入模块: import bokeh [as 别名]
# 或者: from bokeh import palettes [as 别名]
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
示例2: _names_factory
# 需要导入模块: import bokeh [as 别名]
# 或者: from bokeh import palettes [as 别名]
def _names_factory():
return list(sorted(bokeh.palettes.all_palettes.keys()))
示例3: _numbers_factory
# 需要导入模块: import bokeh [as 别名]
# 或者: from bokeh import palettes [as 别名]
def _numbers_factory():
return list(sorted(bokeh.palettes.all_palettes["Viridis"].keys()))