本文介绍了matplotlib 直方图:如何在条形图上显示计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 matplotlib 的 hist 函数,如何让它显示条形图上每个 bin 的计数?
With matplotlib's hist function, how can one make it display the count for each bin over the bar?
例如
import matplotlib.pyplot as plt data = [ ... ] # some data plt.hist(data, bins=10)我们如何使每个 bin 中的计数显示在其条形上?
How can we make the count in each bin display over its bar?
推荐答案好像hist不行,可以这样写:
it seems hist can't do this,you can write some like :
your_bins=20 data=[] arr=plt.hist(data,bins=your_bins) for i in range(your_bins): plt.text(arr[1][i],arr[0][i],str(arr[0][i]))更多推荐
matplotlib 直方图:如何在条形图上显示计数?
发布评论