【发布时间】:2018-12-20 04:10:00
【问题描述】:
我正在尝试使用回调获取散景散点图上套索选定点的数据。
我正在研究此处显示的示例:Bokeh Server callback from tools
from bokeh.plotting import figure, curdoc, show, output_file
from bokeh.models import ColumnDataSource
from bokeh.layouts import column
from bokeh.io import curdoc
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=list('XY'))
source=ColumnDataSource(df)
p = figure(title="Some Figure", tools=["lasso_select"])
pglyph = p.circle(x='X', y='Y', source=source)
def callback(attr, old, new):
# The index of the selected glyph is : new['1d']['indices'][0]
patch_name = source.data['X'][new['1d']['indices'][0]]
print("LassoTool callback executed on Patch {}".format(patch_name))
pglyph.data_source.on_change('selected',callback)
curdoc().add_root(column(p))
#bokeh serve --show TestApp.py
使用 Bokeh Server 运行此脚本时,我需要进行哪些更改才能使打印功能正常工作?这将帮助我了解如何访问所选要素的数据以用作另一个图表的来源。
【问题讨论】:
标签: bokeh