散景:链接图不适用于大尺度

Bokeh: linking plots not working for big scales

修改此处找到的示例代码后http://docs.bokeh.org/en/0.10.0/docs/user_guide/interaction.html#linking-plots 使 Y 轴的值为 [0, 500]

from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.plotting import figure, output_file, show

p = figure(plot_width=400, plot_height=400, tools="tap,wheel_zoom")

high = 1000

x_values = [i/50 for i in range(0,high)]
y_values = [i/2 for i in range(0,high)]

source = ColumnDataSource(data=dict(
    x = x_values,
    y = y_values,
    color  = ['blue']*len(x_values),
    radius = [0.001]*len(x_values)
    ))

p.circle('x', 'y', color='color', source=source, radius = 'radius')

url = "http://www.colors.commutercreative.com/@color/"
taptool = p.select(type=TapTool)
taptool.callback = OpenURL(url=url)

show(p)

--> 点击一个点什么都不做。实际上,如果我们设法在点的确切中心单击,它就会起作用。但不是很人性化。 此外,对于更大的比例 (y = [0, 1000]),单击该点根本没有任何效果。

有趣的是,我注意到删除 "radius" 关键字可以解决问题。但是我确实需要指定半径,所以没用。

请查看这个未解决的问题:https://github.com/bokeh/bokeh/issues/517

是否可以指定屏幕 size 像素,而不是 "data space units" 中的 radius?问题的根源是你在 x 和 y 维度上有非常不同的数据 space 比例。如果不是,您可以尝试指定不同的 radius_dimension 以沿不同的维度进行测量:

http://docs.bokeh.org/en/0.11.1/docs/reference/models/markers.html#bokeh.models.markers.Circle.radius_dimension

另请注意,您提供的 link 是针对旧版本文档的。如果您实际上使用的是旧版本的 Bokeh,那很好,只要确保您知道,以防您认为您正在查看最新的文档。