获取直方图的最大y值

2024-05-20 00:38:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我在寻找如何计算直方图的最大y值的建议。

#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)

Tags: ofthevalueplt直方图simplecanhist
1条回答
网友
1楼 · 发布于 2024-05-20 00:38:49

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

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

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

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

相关问题 更多 >