✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
πŸ‡ Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Express scatter animations giving inconsistent behavior

I have a moderate sized data set of x-y scatter objects that I have placed into groups and sets. Plotting using facet_row, facet_col was starting to make for tiny little subplots due to the large number of facet_rows. I wanted to try animating the data to get a slider make it easier to visualize. The issue is the slider reaches a point where plots stop updating. To illustrate I have defined a simple data set:

data = {
    'x':[  0,  1,  2,  0,  1,  2],
    'y':[  0,  1,  4, .5, 1.5, 18],
    's':[ 10, 10, 10, 20, 20, 20]

data = pd.DataFrame(data)
fig = px.scatter(data, x=β€˜x’, y=β€˜y’, facet_col=β€˜g’, animation_frame=β€˜s’)

The above will give you a slider that uses the β€˜s’ column but when you pull it to 20 and back to 10 the group β€œA” scatter trace is just gone. If I skip trying to animate and use facet_row=β€˜s’ then I get the plot I expect but this approach doesn’t scale will for many different values of s.

fig = px.scatter(data, x='x', y='y', facet_col='g', facet_row='s')

If I pad the data to force both β€˜A’ and β€˜B’ groups to have a least a single NaN for sets 10,20 then the animation appears to work but I would rather not have manually force data points in. I really like the terse compact syntax for adding the animation and would like to use this approach if possible.