Plots

plots.AGP_plot(df: DataFrame, id: str, save: str = None, height: int = 600, app=False)

Graphs AGP-report style plots for the given patient within the given DataFrame. Also saves this plot as both a PDF and HTML file if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plot are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot, defaults to 600

  • app (bool, optional) – boolean indicating whether to return the Plotly figure instead of rendering it (used mainly within the web application), defaults to False

Returns:

None if app is False, otherwise the Plotly figure

Return type:

‘plotly.graph_objects.Figure’ | None

plots.AGP_plot_all(df: DataFrame, height: int = 600, save: str = None)

Graphs AGP-report style plots for all of the patients within the given DataFrame. Also saves these plots as both PDF and HTML files if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plot are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot, defaults to 600

plots.AGP_report(df: DataFrame, id: str, path: str = None)

Creates an AGP-report for the given patient within the given DataFrame. Also saves this plot as a PDF file if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to report on

  • id (str) – the identification of the patient whose CGM data to report on

  • path (str, optional) – path of the location where the saved PDF version of the plot is saved, defaults to None

Returns:

the AGP-report in string form if path is False, otherwise None

Return type:

str | None

plots.create_event_lines(fig: Figure, events: DataFrame)

Marks vertical lines within the given plotly Figure for the given events

Parameters:
  • fig (plotly.graph_objects.Figure) – the plotly figure to mark vertical lines in

  • events (pandas.DataFrame'') – Pandas DataFrame containing vevents to mark

plots.daily_plot(df: DataFrame, id: str, height: int = 2000, events: DataFrame = None, save: bool = False, app: bool = False)

Graphs a daily (time-series) plot for the given patient within the given DataFrame. Also saves this plot as both a PDF and HTML file if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • events ('pandas.DataFrame', optional) – a DataFrame containing any events to mark on the daily plots, defaults to None

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plot are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot, defaults to 2000

  • app (bool, optional) – boolean indicating whether to return the Plotly figure instead of rendering it (used mainly within the web application), defaults to False

Returns:

None if app is False, otherwise the Plotly figure

Return type:

‘plotly.graph_objects.Figure’ | None

plots.daily_plot_all(df: DataFrame, events: DataFrame = None, save: str = None, height: int = 2000)

Graphs daily plots for all of the patients in the given DataFrame. Also saves these plots as PDFs and HTMLs if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • events ('pandas.DataFrame', optional) – a DataFrame containing any events to mark on the daily plots, defaults to None

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plots are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot(s), defaults to 2000

plots.event_plot(df: DataFrame, id: str, event: Series, events: DataFrame = None, save: bool = False, app: bool = False)

Graphs an event plot for the given patient within the given DataFrame.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • event ('pandas.Series') – the event to be displayed

  • events ('pandas.DataFrame', optional) – a DataFrame containing any extra events to be marked within the event plot, defaults to None

  • save (bool, optional) – boolean indicating whether to save the plot as a file, defaults to False

  • app (bool, optional) – boolean indicating whether to return the Plotly figure instead of rendering it (used mainly within the web application), defaults to False

Returns:

None if app is False, otherwise the Plotly figure

Return type:

‘plotly.graph_objects.Figure’ | None

plots.event_plot_all(df: DataFrame, id: str, events: DataFrame, type: str, save: bool = False)

Graphs all event plots of a certain type for the given patient within the given DataFrame.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • events ('pandas.DataFrame') – a DataFrame containing events to be plotted, defaults to None

  • type (str) – the type of events to plot

plots.spaghetti_plot(df: DataFrame, id: str, chunk_day: bool = False, save: str = None, height: int = 600, app=False)

Graphs a spaghetti plot for the given patient within the given DataFrame. Also saves this plot as both a PDF and HTML file if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • chunk_day (bool, optional) – boolean indicating whether to create separate subplots based on whether the data occurred on a weekday or during the weekend

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plots are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot(s), defaults to 600

  • app (bool, optional) – boolean indicating whether to return the Plotly figure instead of rendering it (used mainly within the web application), defaults to False

Returns:

None if app is False, otherwise the Plotly figure

Return type:

‘plotly.graph_objects.Figure’ | None

plots.spaghetti_plot_all(df: DataFrame, chunk_day: bool = False, save: str = None, height: int = 600)

Graphs spaghetti plots for all patients within the given DataFrame. Also saves these plots as PDF and HTML files if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • chunk_day (bool, optional) – boolean indicating whether to create separate subplots based on whether the data occurred on a weekday or during the weekend

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plots are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot(s), defaults to 600

plots.weekly_plot(df: DataFrame, id: str, save: str = None, height: int = 1000, app=False)

Graphs a weekly (time-series) plot for the given patient within the given DataFrame. Also saves this plot as a PDF and HTML if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • id (str) – the identification of the patient whose CGM data to plot within the given DataFrame

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plots are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot, defaults to 1000

  • app (bool, optional) – boolean indicating whether to return the Plotly figure instead of rendering it (used mainly within the web application), defaults to False

Returns:

None if app is False, otherwise the Plotly figure

Return type:

‘plotly.graph_objects.Figure’ | None

plots.weekly_plot_all(df: DataFrame, save: str = None, height: int = 1000)

Graphs weekly plots for all of the patients within the given DataFrame. Also saves these plots as PDF and HTML files if passed a valid path.

Parameters:
  • df ('pandas.DataFrame') – the DataFrame (following package guidelines) containing the CGM data to plot

  • save (str, optional) – path of the location where the saved PDF and HTML versions of the plots are saved, defaults to None

  • height (int, optional) – the height (in pixels) of the resulting plot(s), defaults to 1000