bar_chart_race
bar_chart_race copied to clipboard
Change text format on the bars to float
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?
Inside plot_bars()
method, change this code
text = f'{x1:,.0f}'
to text = f'{x1:,.2f}'
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'
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
Rhitabrat's solution worked for me - thanks!