Bokeh multi_line and HoverTool

谁都会走 提交于 2019-12-11 00:47:14

问题


In Bokeh 0.10.0 we can use HoverTool for lines. But can we use it for multi_line? For example, when running the following code,

from bokeh.models import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.plotting import figure, output_file, show

x = [1, 2, 3, 4, 5]
ys = [[6, 7, 2, 4, 5], [5, 4, 2, 7, 6]]

hover = HoverTool(
    tooltips=[
        ("(x,y)", "($x, $y)"),
        ("label", "@label"),
    ]
)

output_file("test_bokeh.html", title="bokeh feature test")

p = figure(title='figure', x_axis_label='x', y_axis_label='y', tools=[hover])
line_source = ColumnDataSource({
    'x': x,
    'y': x,
    'label': ['single line'] * 5,
})
p.line('x', 'x', source=line_source)
multi_line_source = ColumnDataSource({
    'xs': [x, x],
    'ys': ys,
    'label': ['line 0', 'line_1'],
    'color': ['red', 'blue'],
})
p.multi_line('xs', 'ys', color='color', source=multi_line_source)

show(p)

It correctly displays a tooltip for the line plot but nothing for the multi_line plot. Am I doing something wrong, or is HoverTool not implemented for multi_line?


回答1:


Found from Bokeh reference guide that it is not implemented (yet); see

http://docs.bokeh.org/en/latest/docs/reference/models/tools.html#bokeh.models.tools.HoverTool



来源:https://stackoverflow.com/questions/32975709/bokeh-multi-line-and-hovertool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!