pyplot: loglog() with base e

后端 未结 2 1954
故里飘歌
故里飘歌 2021-01-18 01:09

Python (and matplotlib) newbie here coming over from R, so I hope this question is not too idiotic. I\'m trying to make a loglog plot on a natural log scale. But after some

2条回答
  •  悲哀的现实
    2021-01-18 01:43

    It can also works for semilogx and semilogy to show them in e and also change their name.

    import matplotlib.ticker as mtick
    fig, ax = plt.subplots()
    def ticks(y, pos):
        return r'$e^{:.0f}$'.format(np.log(y))
    
    plt.semilogy(Time_Series, California_Pervalence ,'gray', basey=np.e  )
    ax.yaxis.set_major_formatter(mtick.FuncFormatter(ticks))
    
    plt.show()
    

    Take a look at the image.enter image description here

提交回复
热议问题