import matplotlib.pyplot as plt import pandas as pd from matplotlib.animation import FuncAnimation df = pd.DataFrame( { "col1": [1, 2, 3, 4], "col2": [4, 3, 2, 1], "col3": [5, 6, 7, 8], } ) T = df.T.copy() D = T.to_numpy() C = T.shift(fill_value=0).cumsum().to_numpy() plt.style.use("ggplot") fig, ax = plt.subplots( subplot_kw=dict( xlim=(-0.5, len(df) - 0.5), ylim=(0, df.sum(axis=1).max() + 1), xticks=df.index, ), figsize=(7, 3), ) def stack(i): if i == 0: pass # empty frame else: vals, bot = D[i - 1], C[i - 1] ax.bar(df.index, vals, bottom=bot) ani = FuncAnimation(fig, stack, frames=len(df.columns) + 1)