bar_chart_race icon indicating copy to clipboard operation
bar_chart_race copied to clipboard

Change text format on the bars to float

Open tahershamsi opened this issue 4 years ago • 4 comments

Hi there!

I have a dataframe that the rate of changes is slow. So, I need to see how it changes through two decimals. Is there any way to change the format of the texts on the bars to float with specific decimals?

In the Github page, I've found:

bar_texttemplate='{x:,.0f}'

But I get keyword argument error since I guess it is removed. I cannot find the keyword in the documentation page.

Do you have any ideas how to do this?

tahershamsi avatar Aug 20 '20 10:08 tahershamsi

Inside plot_bars() method, change this code text = f'{x1:,.0f}' to text = f'{x1:,.2f}'

Rhitabrat avatar Jan 08 '21 07:01 Rhitabrat

i guess he was asking about the text on the bars not the period_summary_func i want to show a float number with 2 decimals on bars but cant find how i tried tick_template='{x:,.2f}', but it gave the below error: TypeError: bar_chart_race() got an unexpected keyword argument 'tick_template'

ahmadsss avatar Mar 02 '21 18:03 ahmadsss

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

SandervandenOord avatar Dec 08 '21 13:12 SandervandenOord

Rhitabrat's solution worked for me - thanks!

sjberkeley avatar Sep 27 '23 00:09 sjberkeley