我有一个多行图在bokeh,我想选择一些多线使用套索工具。这在默认情况下不起作用:套索工具不选择任何线条。
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import MultiLine
plot = figure(plot_width=400, plot_height=400, tools="lasso_select")
renderer = plot.multi_line([[1, 2, 3, 4, 5], [0,1]], [[2, 5, 8, 2, 7], [1,0]])
selected_circle = MultiLine(line_alpha=0.5, line_color='firebrick')
nonselected_circle = MultiLine(line_alpha=1, line_color='red')
renderer.selection_glyph = selected_circle
renderer.nonselection_glyph = nonselected_circle
show(plot)当然,问题是如何将一条线视为选定的:这条线的一个点是在套索区域,还是所有点都在套索区域?
我试图添加一些javascript代码来改变lasso工具的行为,但显然多行代码并不像简单的数据点那样工作:
这个密码..。
on_lasso = CustomJS(args=dict(), code='''
console.log(cb_obj.selected);
''')
lasso = LassoSelectTool(callback=on_lasso)
plot = figure(plot_width=800, plot_height=600, tools=[lasso])...tells我认为cb_obj.selected是因为某种原因而没有定义的。
任何帮助都将不胜感激!
PS:我使用bokeh v0.13.0
发布于 2018-08-16 00:40:26
不幸的是,tap以外的其他选择方法似乎无法用于MultiLine。为了让您了解一下历史,tap对MultiLine的支持是在bokeh v0.12.2中实现的;参见GitHub中的bokeh问题#3110。
但是,在调试模式( lasso ) (export BOKEH_DEV=1)中使用CustomJs代码可以在控制台日志中获得以下内容:
[bokeh] 'poly' selection not available for MultiLine bokeh.js:13478此警告只记录一次,请参阅代码,并且很容易被忽略。
我建议在Bokeh GitHub中打开一个特性请求。
https://stackoverflow.com/questions/51722445
复制相似问题