散景,multi_line:如何select几行与方框select?
Bokeh, multi_line: how to select several lines with the box select?
我有一个使用 multi_line 字形创建的散景图。我可以 select 使用点击工具单行或使用 TapTool+Shift 多行。有没有办法 select 使用 BoxSelectTool 的几行(如图所示)?沿每条线的点的密度相当高,所以如果 selection 仅当一条线的 1+ 个点在方框 selection 区域内时才起作用,那也没关系。
我正在寻找没有 Python 服务器的独立解决方案。写一些CustomJS代码就可以了。
from bokeh.models import ColumnDataSource
from bokeh.layouts import column
import numpy as np
output_file('tst.html', mode="inline")
n = 8
t = np.linspace(0., 10., 80)
data = ColumnDataSource(dict(xx=[t for cnt in range(n)],
yy=[(10 + cnt/2*(-1)**cnt)*np.sin(t + cnt/3) for cnt in range(n)],
zz=[(10 - cnt/2*(-1)**cnt)*np.cos(t) for cnt in range(n)]))
f1 = figure(plot_width=800, plot_height=300, tools='tap,box_select,reset')
f2 = figure(plot_width=800, plot_height=300)
f1.multi_line(xs='xx', ys='yy', source=data)
f2.multi_line(xs='xx', ys='zz', source=data)
save(column(f1, f2))
Plot sample with the box selection
谢谢。
此功能不是内置的,至少在 Bokeh 2.0.2 中不是。 MultiLine
字形仅定义 _hit_point
(由点击、悬停和编辑工具使用)和 _hit_span
(由悬停工具使用)方法。要使方框 select 工具起作用,需要定义一个 _hit_rect
方法。自己做并不难,但您必须创建自定义 Bokeh 模型并为其编写一些 TypeScript。
话虽如此,请随时在 Bokeh 上创建功能请求 GitHub!
我有一个使用 multi_line 字形创建的散景图。我可以 select 使用点击工具单行或使用 TapTool+Shift 多行。有没有办法 select 使用 BoxSelectTool 的几行(如图所示)?沿每条线的点的密度相当高,所以如果 selection 仅当一条线的 1+ 个点在方框 selection 区域内时才起作用,那也没关系。 我正在寻找没有 Python 服务器的独立解决方案。写一些CustomJS代码就可以了。
from bokeh.models import ColumnDataSource
from bokeh.layouts import column
import numpy as np
output_file('tst.html', mode="inline")
n = 8
t = np.linspace(0., 10., 80)
data = ColumnDataSource(dict(xx=[t for cnt in range(n)],
yy=[(10 + cnt/2*(-1)**cnt)*np.sin(t + cnt/3) for cnt in range(n)],
zz=[(10 - cnt/2*(-1)**cnt)*np.cos(t) for cnt in range(n)]))
f1 = figure(plot_width=800, plot_height=300, tools='tap,box_select,reset')
f2 = figure(plot_width=800, plot_height=300)
f1.multi_line(xs='xx', ys='yy', source=data)
f2.multi_line(xs='xx', ys='zz', source=data)
save(column(f1, f2))
Plot sample with the box selection
谢谢。
此功能不是内置的,至少在 Bokeh 2.0.2 中不是。 MultiLine
字形仅定义 _hit_point
(由点击、悬停和编辑工具使用)和 _hit_span
(由悬停工具使用)方法。要使方框 select 工具起作用,需要定义一个 _hit_rect
方法。自己做并不难,但您必须创建自定义 Bokeh 模型并为其编写一些 TypeScript。
话虽如此,请随时在 Bokeh 上创建功能请求 GitHub!