bar_chart_race icon indicating copy to clipboard operation
bar_chart_race copied to clipboard

X-axis label number format

Open luispsa opened this issue 4 years ago • 3 comments

Hi,

is there a way to change the number format in X-axis?, in my country the comma is used as decimal separator, I tried to fix this with the import of locale library, but the issue continues...

luispsa avatar Oct 06 '20 18:10 luispsa

Here's another question on the same topic: https://stackoverflow.com/questions/69795740/python-package-bar-chart-race-0-1-0-cant-change-separator-thousands-to-dot

SandervandenOord avatar Dec 08 '21 12:12 SandervandenOord

When you install barchartrace via pip or conda, this currently installs an old version which doesn't allow you to change the text formatting locale.

So, uninstall the version you currently have and install the latest version of bar chart race as follows in your command line. You do need to have git installed for this:

pip uninstall bar_chart_race
pip install git+https://github.com/dexplo/bar_chart_race

And then you set your locale so that you get comma separators for decimals.
Working code example in Jupyter notebooks:

import bar_chart_race as bcr

import locale
locale.setlocale(locale.LC_NUMERIC, "de_DE")

df = bcr.load_dataset('covid19_tutorial')
bcr.bar_chart_race(
    df=df, 
    filename=None, 
    bar_texttemplate='{x:n}', 
    tick_template='{x:n}',
)

SandervandenOord avatar Dec 08 '21 13:12 SandervandenOord

When you install barchartrace via pip or conda, this currently installs an old version which doesn't allow you to change the text formatting locale.

So, uninstall the version you currently have and install the latest version of bar chart race as follows in your command line. You do need to have git installed for this:

pip uninstall bar_chart_race
pip install git+https://github.com/dexplo/bar_chart_race

And then you set your locale so that you get comma separators for decimals. Working code example in Jupyter notebooks:

import bar_chart_race as bcr

import locale
locale.setlocale(locale.LC_NUMERIC, "de_DE")

df = bcr.load_dataset('covid19_tutorial')
bcr.bar_chart_race(
    df=df, 
    filename=None, 
    bar_texttemplate='{x:n}', 
    tick_template='{x:n}',
)

Thank you very much mate! I' waited months for an answer for this issue

regards

luispsa avatar Dec 10 '21 13:12 luispsa