From a0ddbdba6c764bdc0a110afe6ba6cee0a90464d6 Mon Sep 17 00:00:00 2001 From: alondmnt Date: Tue, 3 Sep 2024 03:24:12 +0000 Subject: [PATCH] improved: plot_diet_cgm_sleep calibration --- nbs/16_diet_plots.ipynb | 13 ++++++------- pheno_utils/diet_plots.py | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/nbs/16_diet_plots.ipynb b/nbs/16_diet_plots.ipynb index 563fd8c..d7760d1 100644 --- a/nbs/16_diet_plots.ipynb +++ b/nbs/16_diet_plots.ipynb @@ -110,7 +110,7 @@ " label=label,\n", " return_meals=meals,\n", " return_summary=summary,\n", - " return_units=agg_units,\n", + " agg_units=agg_units,\n", " x_col=x,\n", " )\n", "\n", @@ -576,7 +576,7 @@ " participant_id=None,\n", " array_index=None,\n", " time_range: Tuple[str, str]=None,\n", - " figsize=(14, 8),\n", + " figsize=(14, 10),\n", ") -> TimeSeriesFigure:\n", " \"\"\"\n", " Plot diet, CGM and sleep data together.\n", @@ -599,13 +599,13 @@ "\n", " # Add diet\n", " if diet is not None:\n", - " g.plot(plot_meals_hbars, diet,\n", - " participant_id=participant_id, array_index=array_index, time_range=time_range,\n", - " name='diet_bars', height=2)\n", " g.plot(plot_nutrient_lollipop, diet,\n", " second_y=True if cgm is not None else False,\n", " participant_id=participant_id, array_index=array_index, time_range=time_range,\n", - " size_scale=10, name='diet_glucose', sharex='diet_bars')\n", + " size_scale=10, name='diet_glucose', height=1.5)\n", + " g.plot(plot_meals_hbars, diet,\n", + " participant_id=participant_id, array_index=array_index, time_range=time_range,\n", + " name='diet_bars', sharex='diet_glucose', height=3)\n", "\n", " # Add CGM\n", " if cgm is not None:\n", @@ -644,7 +644,6 @@ "\n", " # Tidy up\n", " g.set_axis_padding(0.03)\n", - " g.set_axis_padding(0.08, ax='diet_bars')\n", " if time_range is not None:\n", " g.set_time_limits(*time_range)\n", " g.set_periodic_ticks('2H', ax='sleep_channels')\n", diff --git a/pheno_utils/diet_plots.py b/pheno_utils/diet_plots.py index beb4c28..4c3bfdc 100644 --- a/pheno_utils/diet_plots.py +++ b/pheno_utils/diet_plots.py @@ -72,7 +72,7 @@ def plot_nutrient_bars( label=label, return_meals=meals, return_summary=summary, - return_units=agg_units, + agg_units=agg_units, x_col=x, ) @@ -525,7 +525,7 @@ def plot_diet_cgm_sleep( participant_id=None, array_index=None, time_range: Tuple[str, str]=None, - figsize=(14, 8), + figsize=(14, 10), ) -> TimeSeriesFigure: """ Plot diet, CGM and sleep data together. @@ -548,13 +548,13 @@ def plot_diet_cgm_sleep( # Add diet if diet is not None: - g.plot(plot_meals_hbars, diet, - participant_id=participant_id, array_index=array_index, time_range=time_range, - name='diet_bars', height=2) g.plot(plot_nutrient_lollipop, diet, second_y=True if cgm is not None else False, participant_id=participant_id, array_index=array_index, time_range=time_range, - size_scale=10, name='diet_glucose', sharex='diet_bars') + size_scale=10, name='diet_glucose', height=1.5) + g.plot(plot_meals_hbars, diet, + participant_id=participant_id, array_index=array_index, time_range=time_range, + name='diet_bars', sharex='diet_glucose', height=3) # Add CGM if cgm is not None: @@ -593,7 +593,6 @@ def plot_diet_cgm_sleep( # Tidy up g.set_axis_padding(0.03) - g.set_axis_padding(0.08, ax='diet_bars') if time_range is not None: g.set_time_limits(*time_range) g.set_periodic_ticks('2H', ax='sleep_channels')