dexplo / bar_chart_race

Create animated bar chart races in Python with matplotlib
MIT License
1.35k stars 351 forks source link

X-axis label number format #33

Open luispsa opened 3 years ago

luispsa commented 3 years ago

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...

SandervandenOord commented 2 years ago

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 commented 2 years ago

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}',
)
luispsa commented 2 years ago

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