散景:连接不适合大规模的地块

时间:2016-05-23 21:43:10

标签: python charts scatter-plot bokeh

修改此处的示例代码后http://bokeh.pydata.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”关键字可以解决问题。但我确实需要指定半径,所以它没有帮助。

1 个答案:

答案 0 :(得分:1)

请参阅此未解决的问题:https://github.com/bokeh/bokeh/issues/517

是否可以指定屏幕size(以像素为单位),而不是radius数据空间单位"?问题的根源是x和y维度中的数据空间比例非常不同。如果没有,您可以尝试指定另一个radius_dimension来衡量不同的维度:

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

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