Logarithmic y-axis bins in python

前端 未结 2 883
时光说笑
时光说笑 2020-11-30 06:32

I\'m trying to create a histogram of a data column and plot it logarithmically (y-axis) and I\'m not sure why the following code does not work:



        
2条回答
  •  旧巷少年郎
    2020-11-30 06:59

    np.logspace returns bins in [1-10], logarithmically spaced - in my case xx is a npvector >0 so the following code does the trick

    logbins=np.max(xx)*(np.logspace(0, 1, num=1000) - 1)/9
    hh,ee=np.histogram(xx, density=True, bins=logbins)
    

提交回复
热议问题