Skip to content
Advertisement

How to format seaborn/matplotlib axis tick labels from number to thousands or Millions? (125,436 to 125.4K)

JavaScript

enter image description here

How can I can change the axis format from a number to custom format? For example, 125000 to 125.00K

Advertisement

Answer

IIUC you can format the xticks and set these:

JavaScript

enter image description here

The key bit here is this line:

JavaScript

So this divides all the ticks by 1000 and then formats them and sets the xtick labels

UPDATE Thanks to @ScottBoston who has suggested a better method:

JavaScript

see the docs

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