Animating Bar chart one after the other

Is it possible to animate a Bar chart so that each bar appears in the animation sequentially?

For example, in the image above, I want for each frame, a new bar to show up but I don’t want the previously rendered ones to disappear thus if I’m at frame 5 then I’d like to show all the bars until that frame.

requests_df = pd.DataFrame({'requests': total_requests})

fig = go.Figure(data = [go.Bar(x=requests_df.index.tolist(), y=requests_df['requests'])],
               frames=[
                    go.Frame(data=[go.Bar(x=requests_df.index.tolist(), y=requests_df['requests'])])] 
     )
 fig.show()

total_requests is a variable with values ranging from tens to hundreds of millions and I used that to create a dataframe since I was trying to make it more convenient in a way to use. Basically, the dataframe looks like this

requests
0 214388438.0
1 194980303.0
2 179475934.0
3 165196540.0
4 154815540.0
5 123650671.0

At first, I tried to accomplish this using express but my attempts did not work out so I started experimenting with go.Figure objects.

1 Like

I adjusted the dataframe in such a way that it looks like this:

frame requests
0 0 214388438.0
1 0 0.0
2 0 0.0
3 0 0.0
4 0 0.0
2299 47 363956605.0
2300 47 334134793.0
2301 47 303192352.0
2302 47 268989809.0
2303 47 241935256.0

Using the code below I managed to generate the sort of animation that I wanted but it’s not working as expected as the bars are not in sync. While I tried to adjust the transition duration, it doesn’t fix the problem.

fig = px.bar(df2, y="requests", animation_frame="frame")
fig.update_layout(transition = {'duration': 3000})
fig.show()