【发布时间】:2019-05-27 10:54:44
【问题描述】:
我遇到了如何使用 Tap 工具在散景图中显示 x 和 y 坐标的问题
我尝试了以下代码。现在我想为点击工具写一个回调,我该怎么做。如何在单击正方形时显示 x 和 y 坐标
from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.plotting import figure, output_file, show
output_file("openurl.html")
p = figure(plot_width=400, plot_height=400,
tools="tap", title="Click the Dots")
source = ColumnDataSource(data=dict(x=[1, 2, 3, 4, 5], y=[2, 5, 8, 2,
7]))
p.square('x', 'y', color='green', size=20, source=source)
taptool = p.select(type=TapTool)
show(p)
【问题讨论】: