biopsykit.sleep.plotting module¶
Module providing functions to plot data collected during sleep studies.
- biopsykit.sleep.plotting.sleep_imu_plot(data, datastreams=None, sleep_endpoints=None, downsample_factor=None, **kwargs)[source]¶
Draw plot to visualize IMU data during sleep, and, optionally, add sleep endpoints information.
- Parameters
data (
DataFrame) – data to plot. Data must either be acceleration data (AccDataFrame), gyroscope data (GyrDataFrame), or IMU data (ImuDataFrame).datastreams (str or list of str, optional) – list of datastreams indicating which type of data should be plotted or
Noneto only plot acceleration data. If more than one type of datastream is specified each datastream is plotted row-wise in its own subplot. Default:Nonesleep_endpoints (
SleepEndpointDict) – dictionary with sleep endpoints to add to plot orNoneto only plot IMU data.downsample_factor (int, optional) – downsample factor to apply to raw input data before plotting or
Noneto not downsample data before plotting (downsample factor 1). Default:None**kwargs –
optional arguments for plot configuration. To configure which type of sleep endpoint annotations to plot:
plot_sleep_onset: whether to plot sleep onset annotations or not: Default:Trueplot_wake_onset: whether to plot wake onset annotations or not: Default:Trueplot_bed_start: whether to plot bed interval start annotations or not: Default:Trueplot_bed_end: whether to plot bed interval end annotations or not: Default:Trueplot_sleep_wake: whether to plot vspans of detected sleep/wake phases or not: Default:True
To style general plot appearance:
axs: pre-existing axes for the plot. Otherwise, a new figure and axes objects are created and returned.figsize: tuple specifying figure dimensionspalette: color palette to plot different axes from input data
To style axes:
xlabel: label of x axis. Default: “Time”ylabel: label of y axis. Default: “Acceleration \([m/s^2]\)” for acceleration data and “Angular Velocity \([°/s]\)” for gyroscope data
To style legend:
legend_loc: location of legend. Default: “lower left”legend_fontsize: font size of legend labels. Default: “smaller”
- Returns
- Return type
tuple[matplotlib.figure.Figure, collections.abc.Iterable[matplotlib.axes._axes.Axes]]