获得直方图的最大y值 [英] obtain the max y-value of a histogram

查看:47
本文介绍了获得直方图的最大y值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关如何计算直方图最大 y 值的建议.

I am looking for suggestions on how to calculate the maximum y-value of a histogram.

#simple histogram. how can I obtain the maximum value of, say, x and y?

import matplotlib.pyplot as plt
hdata = randn(500)
x = plt.hist(hdata)
y = plt.hist(hdata, bins=40)

推荐答案

hist 返回一个包含直方图 bin 位置和 y 值的元组.试试这个:

hist returns a tuple that contains the histogram bin locations and y values. Try this:

y, x, _ = plt.hist(hdata)

print x.max()
print y.max()

注意len(y) = len(x) - 1.

这篇关于获得直方图的最大y值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆