hexbin#

使用随机选择的点自动生成的六边形图。此图表显示了从正态分布中随机选择的500个点,这些点被分成了六边形的瓦片。悬停工具提示显示每个瓦片的信息。

详情

Bokeh APIs:

figure.hexbin

More info:

六边形瓦片

Keywords:

十六进制, 十六进制箱, 悬停, 工具提示

import numpy as np

from bokeh.models import HoverTool
from bokeh.plotting import figure, show

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.scatter(x, y, color="white", size=1)

p.add_tools(HoverTool(
    tooltips=[("count", "@c"), ("(q,r)", "(@q, @r)")],
    mode="mouse", point_policy="follow_mouse", renderers=[r],
))

show(p)