Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Bokeh多线和悬停工具_Python_Python 2.7_Bokeh - Fatal编程技术网

Python Bokeh多线和悬停工具

Python Bokeh多线和悬停工具,python,python-2.7,bokeh,Python,Python 2.7,Bokeh,在Bokeh0.10.0中,我们可以使用鼠标悬停工具来绘制直线。但是我们可以用它来生产多线吗?例如,在运行以下代码时 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]]

在Bokeh0.10.0中,我们可以使用鼠标悬停工具来绘制直线。但是我们可以用它来生产多线吗?例如,在运行以下代码时

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)

它正确显示线图的工具提示,但不显示多线图的工具提示。我是否做错了什么,或者HoverTool没有为multi_line实现?

从Bokeh参考指南中发现它还没有实现(尚未实现);看


您可以检查这个答案,而不是