2015-10-06 52 views
2

在散景0.10.0中,我們可以使用HoverTool來繪製線條。但是我們可以將它用於multi_line嗎?例如,在運行以下代碼時,散景multi_line和HoverTool

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?

回答