How to control scientific notation in matplotlib?

前端 未结 2 1923
你的背包
你的背包 2021-01-12 20:45

This is my data frame I\'m trying to plot:

my_dic = {\'stats\': {\'apr\': 23083904,
                       \'may\': 16786816,
                       \'june\'         


        
相关标签:
2条回答
  • 2021-01-12 21:16

    Adding this line helps to get numbers in a plain format but with ',' which looks much nicer:

    ax.get_yaxis().set_major_formatter(
        matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))
    

    And then I can use int(x)/ to convert to million or thousand as I wish:

    0 讨论(0)
  • 2021-01-12 21:22

    Since you already using pandas

    import matplotlib.pyplot as plt
    my_df.plot(kind='bar')
    plt.ticklabel_format(style='plain', axis='y')
    

    0 讨论(0)
提交回复
热议问题