Bars missing on animation for stacked bar plots


I am trying to animate stacked bar charts ( but I’m running into inconsistencies when using the animation_frame and animation_group arguments.
Example on just 1 frame (1 time value), but I would like to generalize that for several frames:

import pandas as pd 
data = [
    ["08:00:00", 10, 1, "1"],
    ["08:00:00", 70, 2, "1"],
    ["08:00:00", 20, 2, "1"],
    ["08:00:00", 20, 4, "2"],
    ["08:00:00", 30, 5, "2"],
    ["08:00:00", 50, 5, "2"],
df = pd.DataFrame(data=data, columns=["time", "qty", "indicator", "source"])

No animation:, x="indicator", y="qty", range_y=[0, df.groupby(["time", "indicator"])["qty"].sum().max()])


With animation:, x="indicator", y="qty", animation_frame="time", animation_group="qty", 
       range_y=[0, df.groupby(["time", "indicator"])["qty"].sum().max()])


As you can see, the bar on indicator=4 is missing although and weirdly enough, the data seems to be there when I hover on the space.
Note that I use animation_group=“qty” instead of animation_group=“indicator” since I want to keep the detailed distribution on each bar.

Am I missing something or is this a known bug?
Thanks a lot

Hi @cpx10 ,

It seems there is problem when use animation_group=“qty”, because there is same “qty” value on indicator 2 and indicator 4. So the bar on indicator 4 is disappeared.

If you want to keep detail distribution on each bar, you can use animation_group=df.index instead of animation_group="qty".

The code with animation will be like this:, x="indicator", y="qty", animation_frame="time", animation_group=df.index,
        range_y=[0, df.groupby(["time", "indicator"])["qty"].sum().max()+20])


I hope this help.

1 Like