"""
Dotted chart of alarm floods
============================

The dotted chart of process mining (Song & van der Aalst, 2007) plots every
event at its time (here relative to the start of the trace) and its trace. A
highlighted pattern is drawn as a line through its occurrence, revealing its
typical duration and position in the flood.
"""

import matplotlib.pyplot as plt

import spmviz as sv
from spmviz.viz import plot_dotted_chart, plot_gap_distribution

db = sv.datasets.make_alarm_cascades(400, random_state=0)
plot_dotted_chart(db, max_sequences=120, highlight="P-LOWFLOW P-TRIP OP-PUMPSTART")
# %%
# How long do the patterns take?
# ------------------------------
ps = sv.mine(db, 0.08, max_length=4)
plot_gap_distribution(ps, top=10)
plt.show()
