【发布时间】:2020-11-21 19:27:56
【问题描述】:
我想在使用 plt.hist 生成的直方图中添加频率标签。
这是数据:
np.random.seed(30)
d = np.random.randint(1, 101, size = 25)
print(sorted(d))
我在 stackoverflow 上查找了其他问题,例如: Adding value labels on a matplotlib bar chart 及其答案,但显然 plt.plot(kind='bar') 返回的对象与 plt.hist 返回的对象不同,并且在使用“get_height”或“get width”函数时出现错误,如在一些条形图的答案中建议。
同样,通过直方图上的 matplotlib 文档也找不到解决方案。 收到此错误
【问题讨论】:
-
问题是什么?欢迎来到 SO。这不是讨论论坛或教程。请使用tour 并花时间阅读How to Ask 以及该页面上的其他链接。
-
此链接适用于“条形”图表,不适用于“直方图”:Adding value labels on a matplotlib bar chart
标签: python matplotlib histogram frequency-distribution