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

Bar Chart animation transition breaks when uniformtext in layout

Hi Everyone,
My friend and I are having difficulties with the smoothness of the bar animation in plotly express. Here’s the sample data. Here’s the code in case you would like to replicate:

import pandas as pd
import plotly           #(version 4.5.4)
import plotly.express as px
import plotly.io as pio

df = pd.read_csv("datasheet.csv")

fig = px.bar(df, x='Percentage', y='Country', color='Country',
orientation='h', text='Percentage',animation_frame='Year', animation_group='Country',
range_x=[0,100]).update_yaxes(categoryorder='total ascending')

fig.update_layout(uniformtext_minsize=20, uniformtext_mode='hide')
fig.update_traces(texttemplate='%{text}', textposition='inside')

fig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 1000
pio.show(fig)

The code above produces a choppy animation transition. However, the animation works well when the text size/mode arguments in layout are taken out:

fig.update_layout(uniformtext_minsize=20, uniformtext_mode='hide')

Do you know why do uniformtext_minsize and uniformtext_mode make the transition falter?

1 Like

Hi @adamschroeder thanks for the report. This looks like a bug to me and I’ve opened https://github.com/plotly/plotly.js/issues/4789.

1 Like