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?