Skip to content
Advertisement

How to format axis number format to thousands with a comma

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:

JavaScript

Here is the code:

JavaScript

Advertisement

Answer

Use , as format specifier:

JavaScript

Alternatively you can also use str.format instead of format:

JavaScript

With matplotlib.ticker.FuncFormatter:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement