如何在散景中格式化颜色条标签

How to format colorbar label in Bokeh

我已经生成了一个类似于示例的holoviews\Bokehheatmap graph
我在 plot_optscolorbar=True 中添加了一个颜色条,但颜色条的标签显示为科学数字。
如何控制标签的格式? 我尝试执行以下代码但没有成功:

cbf = PrintfTickFormatter(format='0,0')
color_bar = ColorBar(formatter=cbf)

然后将它添加到 plot_opts 但它并没有改变任何东西。

我查看了这个 user guide documentation and this model documentation 但没弄清楚如何实现 属性。

更新
这是完整的代码,但仍然不起作用。

dfqudf.head()  

|INDEX|dow|hour|QUERYTYPE|
|--------|--------|--------|------------|
|72|周日| 0 |205104|
|24|星期一| 0 |210293|
|120|周二| 0 |206381|
|144|星期三| 0 |212874|
|96|星期四| 0 |216195|

hv.extension('bokeh')
colors = ["#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce", "#ddb7b1", "#cc7878", "#933b41", "#550b1d"]
heatmap = hv.HeatMap(data=dfqudf[['hour','dow','QUERYTYPE']]
                     , label="Query Hour by Weekday")

hover = HoverTool(tooltips=[('Num of Queries', '@QUERYTYPE{0,0}')])

formatter = NumeralTickFormatter(format='0,0')  #PrintfTickFormatter(format='%.1f') doesn't work either
color_bar = {'formatter': formatter}
plot_opts = dict(width=900, height=300, xrotation=45, xaxis='top', labelled=[]
                 , tools=[hover], toolbar='below'
                 , colorbar=True, colorbar_opts= color_bar
                )
style = dict(cmap=ListedColormap(colors))

heatmap(plot=plot_opts, style=style)

使用 hv.help(element) 您可以了解可以使用哪些选项自定义元素。支持颜色映射的元素(包括 HeatMap)接受传递给 ColorBar 构造函数的 colorbar_opts 绘图选项。这是一个非常简单的例子:

from bokeh.models import PrintfTickFormatter
formatter = PrintfTickFormatter(format='%.1f')
plot_opts = dict(colorbar=True, colorbar_opts={'formatter': formatter})
hv.HeatMap([(0,0,0), (1,1,1)]).opts(plot=plot_opts)