Black Lives Matter. Please consider donating to Black Girls Code today.

How to change unit in vertical text

I’m using this code to display a bar chart. How can I customize left size unit (from M to millions-in-my-native-language) because my client is not using English ?

import as px

df ="continent == 'Europe' and year == 2007 and pop > 2.e6")
fig =, y='pop', x='country', text='pop')
fig.update_traces(texttemplate='%{text:.2s}', textposition='outside')
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')

1 Like

Hi @hao.dn,

This is the right update to set a country specific thousands separator:

fig.update_yaxes(yaxis = dict(exponentformat= "none", 
                              separatethousands= True)

It replaces 80M by 80,000,000.

But if in your country thousands are separated by a dot, i.e. 80.000.0000, then this layout update must be performed, too:

fig.update_layout(separators =',.')


thank but actually I want to replace M (millions) to my native language. How can I archive that ?


Could you please tell us how are denoted millions in your country?

in my country we use Tr (short of “Triệu” - millions ) instead M (short of “Millions”).

In this case in the yaxis definition, set the attributes tickvals and ticktext as follows:

yaxis_tickvals= [10000000*k for k in range(1, 8)]  #these are the positions where the strings in tiktet will be placed
yaxis_ticktext=['10Tr', '20Tr' '30Tr', '40Tr', '50Tr', '60Tr', '70Tr', '80Tr']