【发布时间】:2018-02-15 16:57:04
【问题描述】:
我有一个带有多个字形的图 (figure)(由 plot.circle 绘制)我想同时选择所有图层。我为每个circle 应用了一个CDSFilter。我也使用legend 来隐藏或显示它们。我想要做的是只选择可见的字形点。
# [...]
plot = figure(
width=600,
height=600,
x_range=x_range,
y_range=y_range,
x_axis_label='X',
y_axis_label='Y',
tools='', # they are added later
)
for key in flags:
view = CDSView(source=self.source, filters=[IndexFilter(flags[key])])
g = plot.circle(
x='X', y='Y',
size=5,
fill_color=colors[key],
legend='FLAG {}'.format(key),
line_color=None,
selection_color='red',
source=self.source,
view=view,
)
g.nonselection_glyph = None # avoids to alter the color of the nonselected points
plot.legend.location = "top_left"
plot.legend.click_policy = "hide"
# [...]
lasso_select = LassoSelectTool(
# renderers=self.glyph_rends, # default >> all renderers inside the plot, this is not working either
select_every_mousemove=False,
)
tools = (
wheel_zoom, pan, box_zoom, box_select, lasso_select,
crosshair, tap, save, reset, hover
)
plot.add_tools(*tools)
正如您在图像中看到的,仅选择了绿点,未选择蓝点。当前选择以红色绘制。如果我用图例上的按钮隐藏绿色点,那么我可以选择蓝色点。如果我使用 Tap 工具,那么它会按预期工作,即使我使用 Lasso Tool 仅选择一个点。
更新
【问题讨论】:
标签: python python-3.x plot bokeh