✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Python set locale

How can I set the localization in plotly python. I want to display y axis as currency in indian format (Rupees Lakhs Crores)

Hi @agsharath, welcome to the forum!

You can use a ticks prefix or suffix if you want to add symbols, as described here https://stackoverflow.com/questions/58140143/add-currency-symbol-in-the-y-axis-scale-using-plotly-method-in-python/58142945#58142945. If you want to have different symbols, you can use tickformatstops as described in https://plot.ly/python/tick-formatting/#tickformatstops-to-customize-for-different-zoom-levels.

Also see https://plot.ly/python/axes/#enumerated-ticks-with-tickvals-and-ticktext for the use of tickprefix.

Thanks, I did read about these, but there is much more to formatting currency than tick prefixes, for example, grouping separators, grouping symbols, units (in India we use Lakhs and Crores, not millions and billions) So I’m surprised that plotly doesn’t support full Locale customizations. Anyway I’ll use what you mentioned. Thanks!

Don’t hesitate to post here screenshots (possibly obtained with other software) so that we can get an idea of what is missing. Thanks!

In India, the number system is formatted like this

1 (One)
10 (Ten)
100 (Hundred)
1,000 (Thousand)
10,000 (Ten Thousand)
1,00,000 (One Lakh)
10,00,000 (Ten Lakhs)
1,00,00,000 (One Crore)
10,00,00,000 (Ten Crores)
1,00,00,00,000 (Hundred Crores)
10,00,00,00,000 (Thousand Crores)
1,00,00,00,00,000 (Ten Thousand Crores)
10,00,00,00,00,000 (One Lakh Crore)

and it goes on.

The grouping is 2 except at the beginning. Thousand is written as 1,000

There is a symbol for rupee (the unit of currency) https://en.wikipedia.org/wiki/Indian_rupee_sign

Furthermore, the suffix for unit is different.

For thousands, it is ok to use K for example 10,000 is 10K

but for lakhs, we use L

For example 10,00,000 (Ten lakhs) would be 10L

Crores is abbreviated as C or Cr

So 10,00,00,000 (ten crores) would be 10 Cr or 10 C

Thanks

Sharath

It would be great if I could define a function which would accept a number value and return the desired label as string (for the axes)
That way, I dont have to mess with the logic of spacing the grid lines, dealing with zoom etc.

Plotly can decide the values where the tick marks are placed depending on the zoom level

I can simply specify the logic for generating the label given the value.