Plot 无法使用bokeh BoxSelectTool访问选择
我可以将BoxSelectTool添加到绘图中Plot 无法使用bokeh BoxSelectTool访问选择,plot,bokeh,Plot,Bokeh,我可以将BoxSelectTool添加到绘图中 plot.add_tools(BoxSelectTool(dimensions="both")) 工具出现了,我做了一个矩形选择。但是记录的方法没有显示选定点的任何内容 source.selected.indices []已返回。 怎么了?如何获取选定的索引 在完成这些文章之后,我可以让嵌入式服务器工作,source.selected.index确实返回点,但是call_仍然不起作用 def callback(attr, old, new):
plot.add_tools(BoxSelectTool(dimensions="both"))
工具出现了,我做了一个矩形选择。但是记录的方法没有显示选定点的任何内容
source.selected.indices
[]已返回。
怎么了?如何获取选定的索引
在完成这些文章之后,我可以让嵌入式服务器工作,source.selected.index确实返回点,但是call_仍然不起作用
def callback(attr, old, new):
print('select changed')
# The index of the selected glyph is : new['1d']['indices'][0]
patch_name = source.data['name'][new['1d']['indices'][0]]
print("TapTool callback executed on Patch {}".format(patch_name))
source.on_change('selected',callback)
有什么想法吗?您是否真的将其作为Bokeh服务器应用程序(可能嵌入到笔记本中)运行?如果不是,如果您只是调用
show
或save
来生成静态HTML输出,那么python和浏览器之间就没有同步(执行这种同步的是Bokeh服务器)。谢谢您的评论。这是在jupyter笔记本中,因此不涉及Bokeh服务器。因此,如果运行的都是笔记本,那么如何访问source.selected.index?我会把服务器嵌入笔记本吗?你能告诉我怎么做吗?我跟着。但也没有什么能证明这一点。仍然没有显示任何内容。谢谢。现在它起作用了。我将在博克论坛上发布。