yasa.Hypnogram.plot_hypnogram#
- Hypnogram.plot_hypnogram(highlight='REM', fill_color=None, ax=None, **kwargs)[source]#
Plot the hypnogram.
- Parameters:
- highlightstr or None
Optional stage to highlight with alternate color.
- fill_colorstr or None
Optional color to fill space above hypnogram line.
- ax
matplotlib.axes.Axes Axis on which to draw the plot, optional.
- **kwargsdict
Keyword arguments controlling hypnogram line display (e.g.,
lw,linestyle). Passed tomatplotlib.pyplot.stairsandmatplotlib.pyplot.hlines.
- Returns:
- ax
matplotlib.axes.Axes Matplotlib Axes
- ax
Examples
>>> from yasa import simulate_hypnogram >>> import matplotlib.pyplot as plt >>> hyp = simulate_hypnogram(tib=300, seed=11) >>> ax = hyp.plot_hypnogram() >>> plt.tight_layout()
>>> from yasa import Hypnogram >>> values = 4 * ["W", "N1", "N2", "N3", "REM"] + ["ART", "N2", "REM", "W", "UNS"] >>> hyp = Hypnogram(values, freq="24min").upsample("30s") >>> ax = hyp.plot_hypnogram(lw=2, fill_color="thistle") >>> plt.tight_layout()
>>> from yasa import simulate_hypnogram >>> import matplotlib.pyplot as plt >>> fig, axes = plt.subplots(nrows=2, figsize=(6, 4), constrained_layout=True) >>> hyp_a = simulate_hypnogram(n_stages=3, seed=99) >>> hyp_b = simulate_hypnogram(n_stages=3, seed=99, start="2022-01-31 23:30:00") >>> ax = hyp_a.plot_hypnogram(lw=1, fill_color="whitesmoke", highlight=None, ax=axes[0]) >>> ax = hyp_b.plot_hypnogram(lw=1, fill_color="whitesmoke", highlight=None, ax=axes[1])