How do I format axis number format to thousands with a comma in matplotlib?

后端 未结 7 1572
野性不改
野性不改 2020-11-29 20:48

How can I change the format of the numbers in the x-axis to be like 10,000 instead of 10000? Ideally, I would just like to do something like this:<

相关标签:
7条回答
  • 2020-11-29 21:41
    x = [10000.21, 22000.32, 10120.54]
    

    Perhaps make a list (comprehension) for the labels, and then apply them "manually".

    xlables = [f'{label:,}' for label in x]
    plt.xticks(x, xlabels)
    
    0 讨论(0)
提交回复
热议问题