我有两个数组,x
和 y
,它们的值都在明确定义的范围内。我能够创建一个 hexbin 图 ( see image ),但是,我现在想对这些分布进行归一化并在它们周围绘制等高线图。我对每个 hexbin 中的计数不太感兴趣。相反,我感兴趣的是显示对应于 1、2 和 3 个标准差 (σ) 的等高线。我希望输出显示类似于 this 的轮廓例子。分布是高斯分布。如果对此有任何意见,我将不胜感激。
最佳答案
根据 hexbin 文档 https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.hexbin.html您应该能够访问 bin 的 (x,y) 位置和返回变量的值。例如:
h = hexbin(...)
xy = h.get_offsets()
v = h.get_array()
您可以使用这些来绘制轮廓。
请注意,文档不正确,并说应该调用 get_offset()
,但该函数不存在,它是 get_offsets()
。
此外,当 hexbin
被 xscale='log'
和 yscale='log'
调用时,则 get_offsets( )
仅返回 array([[0., 0.]])
。
关于python - 如何在 hexbin 图上绘制等高线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11639202/