"""
Time-aware icicles (LifeFlow)
=============================

LifeFlow (Wongsuphasawat et al., 2011) aggregates sequences into a tree and
places each node at the *mean time* elapsed since the start, so the horizontal
gaps show how long the steps take. Here the days of the three personas: early
birds reach their first coffee quickly, remote workers start work right after it.
"""

import matplotlib.pyplot as plt

import spmviz as sv
from spmviz.viz import plot_icicle

db = sv.datasets.make_daily_routines(300, random_state=0)
plot_icicle(db, max_depth=5, min_count=15, time_aware=True, title="mean time since waking up (hours)")
# %%
# One persona at a time
# ---------------------
fig, axes = plt.subplots(3, 1, figsize=(9, 10))
for ax, (who, sub) in zip(axes, db.split("persona").items()):
    plot_icicle(sub, ax=ax, max_depth=5, min_count=5, time_aware=True, title=who)
plt.show()
