散景multi_line和HoverTool [英] Bokeh multi_line and HoverTool

查看:60
本文介绍了散景multi_line和HoverTool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Bokeh 0.10.0中,我们可以将HoverTool用于线条.但是我们可以将其用于multi_line吗?例如,运行以下代码时,

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)

它正确显示了线图的工具提示,但没有显示multi_line图的工具提示.我是在做错什么,还是没有为multi_line实现HoverTool?

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?

推荐答案

从Bokeh参考指南中发现它尚未实现(尚未);参见

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

这篇关于散景multi_line和HoverTool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆