plotting a histogram on a Log scale with Matplotlib

后端 未结 3 872
时光取名叫无心
时光取名叫无心 2020-12-08 22:43

I have a pandas DataFrame that has the following values in a Series

x = [2, 1, 76, 140, 286, 267, 60, 271, 5, 13, 9, 76, 77, 6, 2, 27, 22, 1, 12, 7, 19, 81,          


        
3条回答
  •  被撕碎了的回忆
    2020-12-08 23:23

    plot another histogram with the log of x.

    is not the same as plotting x on the logarithmic scale. Plotting the logarithm of x would be

    np.log(x).plot.hist(bins=8)
    plt.show()
    

    The difference is that the values of x themselves were transformed: we are looking at their logarithm.

    This is different from plotting on the logarithmic scale, where we keep x the same but change the way the horizontal axis is marked up (which squeezes the bars to the right, and stretches those to the left).

提交回复
热议问题