【发布时间】:2018-02-11 23:23:23
【问题描述】:
我已经生成了一个holoviews \ Bokeh heatmap graph 类似于示例。
我在plot_opts 和colorbar=True 中添加了一个颜色条,但颜色条的标签显示为科学数字。
如何控制标签的格式?
我尝试实现以下代码但没有成功:
cbf = PrintfTickFormatter(format='0,0')
color_bar = ColorBar(formatter=cbf)
然后将其添加到plot_opts,但它没有改变任何东西。
我查看了这个user guide documentation 和这个model documentation,但没有设法弄清楚如何实现该属性。
更新
这是完整的代码,但仍然无法正常工作。
dfqudf.head()
|INDEX|道指|小时|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)
【问题讨论】: