问题描述
用于补丁的悬停工具与其他字形是否不同?该图可以看到圆圈的索引,但看不到补丁的索引.
Is the hover tool for patch different than other glyphs? The plot can see the index for circle but not for patch.
output_file("patch.html")
TOOLTIPS = [
("index", "$index"),
]
p = figure(plot_width=400, plot_height=400, tooltips=TOOLTIPS, tools='hover,help')
# add a patch renderer with an alpha an line width
p.patch([1, 2, 3, 4, 5], [6, 7, 8, 7, 3], alpha=0.5, line_width=2)
p.circle([2], [4],size=20, line_width=2)
show(p)
推荐答案
从Bokeh 1.0.2版本开始,尚未针对Patch实施点击测试,也就是说,就悬停工具而言,它是不可见的.您可以改用向量化的patches
字形方法:
As of Bokeh 1.0.2, hit testing has not been implemented for Patch, i.e. it is invisible as far as the Hover tool is concerned. You could use the vectorized patches
glyph method instead:
p.patches([[1, 2, 3, 4, 5]], [[6, 7, 8, 7, 3]], alpha=0.5, line_width=2)
但是,由于只有一个补丁(其索引为0),因此这将始终仅返回0作为$index
的值.如果要获取补丁顶点的索引"值,则需要执行一些操作,例如在与顶点相同的位置绘制不可见的圆,仅用于进行命中测试(驱动悬停工具) )
However, this will always only return 0 as the value of $index
since there is only just the one patch (whose index is 0). If you are looking to get "index" values for the vertices of the patch, you will need to do something like plot invisible circles at the same locations as the vertices, that are only there for hit-testing purposes (to drive the hover tool)
这篇关于散景Hovertool补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!