令人惊讶的是,没有人愿意在bokeh图片库中为2D直方图绘图做一个例子。
histogram2d of numpy给出了原材料,但是最好给出一个matplotlib的例子
有什么办法能做得到吗?
接下来是一个建议的答案,让我附上一个案例,在这个案例中,因为exagons不适合这个工作,所以己宾不工作。还可以查看matplotlib结果。
当然,我并不是说bokeh不能这么做,但它似乎不那么简单。这足以将六边图更改为正方形的平面图,但quad(left, right, top, bottom, **kwargs)似乎没有这样做,hexbin也没有改变“平铺”形状的选项。


发布于 2018-06-22 13:44:33
您可以使用相对较少的代码行(与matplotib库中的这示例相结合)来进行比较接近的操作。注bokeh在图库这里和这里中有一些十六进制绑定示例。通过调整这些内容和矮胖的医生中提供的示例,您可以得到以下内容:
import numpy as np
from bokeh.plotting import figure, show
from bokeh.layouts import row
# normal distribution center at x=0 and y=5
x = np.random.randn(100000)
y = np.random.randn(100000) + 5
H, xe, ye = np.histogram2d(x, y, bins=100)
# produce an image of the 2d histogram
p = figure(x_range=(min(xe), max(xe)), y_range=(min(ye), max(ye)), title='Image')
p.image(image=[H], x=xe[0], y=ye[0], dw=xe[-1] - xe[0], dh=ye[-1] - ye[0], palette="Spectral11")
# produce hexbin plot
p2 = figure(title="Hexbin", match_aspect=True)
p.grid.visible = False
r, bins = p2.hexbin(x, y, size=0.1, hover_color="pink", hover_alpha=0.8, palette='Spectral11')
show(row(p, p2))

https://stackoverflow.com/questions/50975814
复制相似问题