Plot Bokeh图表:条形图的自定义工具变量

Plot Bokeh图表:条形图的自定义工具变量,plot,charts,hover,tooltip,bokeh,Plot,Charts,Hover,Tooltip,Bokeh,如果我做一个这样的条形图: bar = Bar(data,labels,tools='Hover') hover = bar.select(dict(type=HoverTool)) hover.tooltips = [ ('Grade',' $x'), ('Students',' @Students'), ] 我可以制作如下工具提示: bar = Bar(data,labels,tools='Hover') hover = bar.s

如果我做一个这样的条形图:

  bar = Bar(data,labels,tools='Hover')
  hover = bar.select(dict(type=HoverTool))

  hover.tooltips = [
      ('Grade',' $x'),
      ('Students',' @Students'),
    ]
我可以制作如下工具提示:

  bar = Bar(data,labels,tools='Hover')
  hover = bar.select(dict(type=HoverTool))

  hover.tooltips = [
      ('Grade',' $x'),
      ('Students',' @Students'),
    ]
但是,当我在工具提示中使用“@variable”执行变量时,我仅限于在数据中指定的变量。在普通Bokeh图中,我可以通过使用ColumnDataSource来拥有与数据点关联的自定义变量。Bar不支持ColumnDataSources。是否有其他方法使自定义变量在Bokeh图表工具提示(悬停)中可用?

将此功能添加到图表界面是一个开放的窗口。

它将成为下一个bokeh版本的一部分,如果您需要的话,还可以通过开发版本(当然也可以在主分支中)在合并后尽快提供

我也有同样的问题。这里的技巧是使用
GlyphRenderer
使条形图知道数据源。例如,您可以添加一行
bar.select(dict(type=GlyphRenderer))
hover=bar.select(dict(type=HoverTool))
之前。然后,您可以使用
@cat
@zero
等引用自定义变量。有关更多信息和工作示例,请参阅以下链接