raphaelvallat / yasa

YASA (Yet Another Spindle Algorithm): a Python package to analyze polysomnographic sleep recordings.
https://raphaelvallat.com/yasa/
BSD 3-Clause "New" or "Revised" License
417 stars 113 forks source link

Add plot_transition_matrix function #6

Closed raphaelvallat closed 4 years ago

raphaelvallat commented 4 years ago

The following snippet can be used to plot a transition matrix probs obtained with the yasa.transition_matrix function:

grid_kws = {"height_ratios": (.9, .05), "hspace": .1}
f, (ax, cbar_ax) = plt.subplots(2, gridspec_kw=grid_kws, figsize=(5, 5))
sns.heatmap(probs, ax=ax, square=False, vmin=0, vmax=1, cbar=True, cbar_ax=cbar_ax,
            cmap='YlOrRd', annot=True, fmt='.2f',
            cbar_kws={"orientation": "horizontal", 'fraction': 0.1, 'label': 'Transition probability'})
ax.set_xlabel("To sleep stage")
ax.xaxis.tick_top()
ax.set_ylabel("From sleep stage")
ax.xaxis.set_label_position('top')

For now, I will not implement it in YASA as it would require adding Seaborn as a dependency

raphaelvallat commented 4 years ago

Added example in API documentation: https://github.com/raphaelvallat/yasa/commit/988972c9c00213bd82598ab0f90eeae7090eba5b