matplotlib histogram: how to display the count over the bar?

后端 未结 1 1520
旧时难觅i
旧时难觅i 2020-12-31 10:07

With matplotlib\'s hist function, how can one make it display the count for each bin over the bar?

For example,

import matplotlib.pyplot         


        
相关标签:
1条回答
  • 2020-12-31 10:43

    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]))
    
    0 讨论(0)
提交回复
热议问题