How to control scientific notation in matplotlib?

前端 未结 2 1941
你的背包
你的背包 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:

提交回复
热议问题