Skip to content

Commit

Permalink
improved: plot_diet_cgm_sleep calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
alondmnt committed Sep 3, 2024
1 parent de30a05 commit a0ddbdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions nbs/16_diet_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 6 additions & 7 deletions pheno_utils/diet_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit a0ddbdb

Please sign in to comment.