【发布时间】:2018-09-25 23:20:00
【问题描述】:
我使用的是 Bokeh 0.12.15 版本,它生成了一个很棒的 hexbin 图。 我想知道如何轻松找到每个六边形的值的索引?
例如下面的代码 (https://docs.bokeh.org/en/latest/docs/gallery/hexbin.html):
import numpy as np
from bokeh.io import output_file, show
from bokeh.models import HoverTool
from bokeh.plotting import figure
n = 500
x = 2 + 2*np.random.standard_normal(n)
y = 2 + 2*np.random.standard_normal(n)
p = figure(title="Hexbin for 500 points", match_aspect=True,
tools="wheel_zoom,reset", background_fill_color='#440154')
p.grid.visible = False
r, bins = p.hexbin(x, y, size=0.5, hover_color="pink", hover_alpha=0.8)
p.circle(x, y, color="white", size=1)
hover = HoverTool(tooltips=[("count", "@c"), ("(q,r)", "(@q, @r)")],
mode="mouse", point_policy="follow_mouse", renderers=[r])
p.add_tools(hover)
output_file("hexbin.html")
show(p)
我想为每个 hexbin 找到其中的元组 (x,y) 的索引
谢谢
【问题讨论】:
-
您是否尝试将 x、y 值显示为工具提示?
-
不,我需要用于某种过滤的值
标签: python coordinates bokeh coordinate-transformation hexagonal-tiles