获取垃圾箱直方图python的中心
I'm using the hist2d
function of matplotlib.pyplot
, giving it input some coordinates (x,y)
.
I would like, after having defined the histogram, to get the center of each bin, i.e., the coordinates of the center of each bin.
Is there an easy way to get them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
plt.plt.hist.hist
和 >包括垃圾箱边缘,因此请按左边缘和右边缘的平均值:plt.hist
如果首选,您可以使用Numpy函数,尽管在这种情况下我发现它不太可读:
plt.hist2d
:输出:
The return values of
plt.hist
andplt.hist2d
include bin edges, so take the mean of the left edges and right edges:plt.hist
plt.hist2d
Note that you can use numpy functions if preferred, though I find it less readable in this case:
Full example with
plt.hist2d
:Output: