Logarithmic y-axis bins in python

前端 未结 2 881
时光说笑
时光说笑 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 07:04

    try

    plt.yscale('log', nonposy='clip')
    

    http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.yscale

    The issue is with the bottom of bars being at y=0 and the default is to mask out in-valid points (log(0) -> undefined) when doing the log transformation (there was discussion of changing this, but I don't remember which way it went) so when it tries to draw the rectangles for you bar plot, the bottom edge is masked out -> no rectangles.

提交回复
热议问题