我正在尝试使用matplotlib和Python从hexbin()方法绘制的六边形中获取顶点。使用.get_arrays()获取每个六边形中的点数,并尝试使用get_paths()获取顶点坐标,但它只给出一个路径(即仅1个六边形的顶点)。
如何检索所有六边形的顶点?下面是尝试的代码及输出。
x, y = np.random.normal(size=(2, 10000))
fig, ax = plt.subplots()
im = ax.hexbin(x, y, gridsize=20)
paths=im.get_paths()
print(paths)
fig.colorbar(im, ax=ax)
正在生成的输出地图拥有超过一个六边形。由于我是新手,帐户受到限制,无法上传它。
[Path(array([[ 0.18489907, -0.1102285 ],
[ 0.18489907, 0.1102285 ],
[ 0. , 0.22045701],
[-0.18489907, 0.1102285 ],
[-0.18489907, -0.1102285 ],
[ 0. , -0.22045701],
[ 0.18489907, -0.1102285 ]]), array([ 1, 2, 2, 2, 2, 2, 79], dtype=uint8))]