r"""
UpSet view of frequent theme combinations
=========================================

UpSet plots (Lex et al. 2014) list set intersections as columns of a dot
matrix with bar charts. Applied to a hypergraph of frequent itemsets, every
column is a combination of themes and its bar is the support.
"""

# %%
import hatvis as hv
from hatvis.plotting import plot_upset

T = hv.datasets.make_news_transactions(n_per_period=150, random_state=0)
# [snippet:upset]
fi = hv.frequent_itemsets(T, min_support=0.06, min_size=2)
IH = hv.itemset_hypergraph(fi.head(18))
fig, axes = plot_upset(IH, title="the 18 most frequent theme combinations")
# [/snippet:upset]
print(fi.head(8).to_string())
