@@ -68,6 +68,7 @@ def plot_daily(cgm_timeseries: pd.Series, lower: int = 70, upper: int = 140) ->
6868 fig .tight_layout ()
6969 return fig
7070
71+
7172def plot_statistics (cgm_timeseries : pd .Series , lower : int = 70 , upper : int = 140 ) -> plt .Figure :
7273 """
7374 Plot statistical representation of daily trends
@@ -89,7 +90,6 @@ def plot_statistics(cgm_timeseries: pd.Series, lower: int = 70, upper: int = 140
8990 time_diffs = cgm_timeseries .index .to_series ().diff ()
9091 dt0 = int (time_diffs .mode ().iloc [0 ].total_seconds () / 60 )
9192
92-
9393 # Create time grid
9494 start_time = cgm_timeseries .index .min ().floor ("D" )
9595 end_time = cgm_timeseries .index .max ().ceil ("D" )
@@ -124,13 +124,13 @@ def plot_statistics(cgm_timeseries: pd.Series, lower: int = 70, upper: int = 140
124124 fig , ax = plt .subplots (figsize = (12 , 6 ))
125125
126126 # plot mean sample trends
127- ax .plot (time_grid_one_day ,mean_sample_trends , color = "orange" , alpha = 1 , linewidth = 3 , label = ' Mean sample trends' )
127+ ax .plot (time_grid_one_day , mean_sample_trends , color = "orange" , alpha = 1 , linewidth = 3 , label = " Mean sample trends" )
128128
129129 # plot quantiles
130- ax .fill_between (time_grid_one_day , quantiles [0 ], quantiles [1 ], alpha = 0.25 , color = "blue" ,label = ' 10% quantile' )
131- ax .fill_between (time_grid_one_day , quantiles [1 ], mean_sample_trends , alpha = 0.50 , color = "blue" ,label = ' 25% quantile' )
132- ax .fill_between (time_grid_one_day , mean_sample_trends , quantiles [2 ], alpha = 0.50 , color = "blue" ,label = ' 75% quantile' )
133- ax .fill_between (time_grid_one_day , quantiles [2 ], quantiles [3 ], alpha = 0.25 , color = "blue" ,label = ' 90% quantile' )
130+ ax .fill_between (time_grid_one_day , quantiles [0 ], quantiles [1 ], alpha = 0.25 , color = "blue" , label = " 10% quantile" )
131+ ax .fill_between (time_grid_one_day , quantiles [1 ], mean_sample_trends , alpha = 0.50 , color = "blue" , label = " 25% quantile" )
132+ ax .fill_between (time_grid_one_day , mean_sample_trends , quantiles [2 ], alpha = 0.50 , color = "blue" , label = " 75% quantile" )
133+ ax .fill_between (time_grid_one_day , quantiles [2 ], quantiles [3 ], alpha = 0.25 , color = "blue" , label = " 90% quantile" )
134134
135135 ax .axhline (y = upper , color = "orange" , linestyle = "--" , alpha = 0.7 , label = f"Hyper threshold ({ upper } mg/dL)" )
136136 ax .axhline (y = lower , color = "green" , linestyle = "--" , alpha = 0.7 , label = f"Hypo threshold ({ lower } mg/dL)" )
0 commit comments