本文整理匯總了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()))