Skip to content

Commit

Permalink
improved: headings in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alondmnt committed Nov 12, 2024
1 parent e776d8b commit 001d8c6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
7 changes: 7 additions & 0 deletions nbs/06_sleep_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to plot sleep events and channels"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
10 changes: 9 additions & 1 deletion nbs/15_timeseries_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
"\n",
"\n",
"def format_xticks(ax: plt.Axes, xticks: Iterable=None, format: str=TIME_FORMAT, **kwargs):\n",
" \"\"\" format datestrings on x axis \"\"\"\n",
" \"\"\" Format datestrings on x axis \"\"\"\n",
" if xticks is None:\n",
" xticks = ax.get_xticks()\n",
" ax.set_xticks(xticks)\n",
Expand Down Expand Up @@ -484,6 +484,7 @@
" unique (bool): Whether to remove duplicate rows.\n",
"\n",
" Returns:\n",
"\n",
" pd.DataFrame: The filtered DataFrame\n",
" \"\"\"\n",
" if participant_id is not None:\n",
Expand Down Expand Up @@ -837,6 +838,13 @@
" return colors"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to plot time series"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
15 changes: 13 additions & 2 deletions nbs/16_diet_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"\n",
" Returns:\n",
"\n",
" None: The function creates a lollipop plot with pie charts on the specified or newly created axis.\n",
" plt.Axes: The Matplotlib axis on which the chart was plotted.\n",
" \"\"\"\n",
" # Prepare the data for plotting\n",
" df, grouped_nutrients = prepare_meals(\n",
Expand Down Expand Up @@ -514,6 +514,10 @@
" alpha (float): The transparency of the bars. Default is 0.7.\n",
" ax (Optional[plt.Axes]): The Matplotlib axis on which to plot the lollipop chart. If None, a new axis is created. Default is None.\n",
" figsize (Tuple[float, float]): The size of the figure to create. Default is (12, 6).\n",
"\n",
" Returns:\n",
"\n",
" plt.Axes: The Matplotlib axis on which the chart was plotted.\n",
" \"\"\"\n",
" diet_log = format_timeseries(\n",
" diet_log, participant_id, array_index,\n",
Expand Down Expand Up @@ -636,7 +640,7 @@
"\n",
" Returns:\n",
"\n",
" TimeSeriesFigure: Plot.\n",
" TimeSeriesFigure: The figure object containing the plots.\n",
" \"\"\"\n",
" g = TimeSeriesFigure(figsize=figsize)\n",
"\n",
Expand Down Expand Up @@ -695,6 +699,13 @@
" return g"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to plot diet logs"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
8 changes: 6 additions & 2 deletions pheno_utils/diet_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def plot_nutrient_lollipop(
Returns:
None: The function creates a lollipop plot with pie charts on the specified or newly created axis.
plt.Axes: The Matplotlib axis on which the chart was plotted.
"""
# Prepare the data for plotting
df, grouped_nutrients = prepare_meals(
Expand Down Expand Up @@ -470,6 +470,10 @@ def plot_meals_hbars(
alpha (float): The transparency of the bars. Default is 0.7.
ax (Optional[plt.Axes]): The Matplotlib axis on which to plot the lollipop chart. If None, a new axis is created. Default is None.
figsize (Tuple[float, float]): The size of the figure to create. Default is (12, 6).
Returns:
plt.Axes: The Matplotlib axis on which the chart was plotted.
"""
diet_log = format_timeseries(
diet_log, participant_id, array_index,
Expand Down Expand Up @@ -585,7 +589,7 @@ def plot_diet_cgm_sleep(
Returns:
TimeSeriesFigure: Plot.
TimeSeriesFigure: The figure object containing the plots.
"""
g = TimeSeriesFigure(figsize=figsize)

Expand Down
3 changes: 2 additions & 1 deletion pheno_utils/timeseries_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def show(self) -> None:


def format_xticks(ax: plt.Axes, xticks: Iterable=None, format: str=TIME_FORMAT, **kwargs):
""" format datestrings on x axis """
""" Format datestrings on x axis """
if xticks is None:
xticks = ax.get_xticks()
ax.set_xticks(xticks)
Expand Down Expand Up @@ -445,6 +445,7 @@ def format_timeseries(
unique (bool): Whether to remove duplicate rows.
Returns:
pd.DataFrame: The filtered DataFrame
"""
if participant_id is not None:
Expand Down

0 comments on commit 001d8c6

Please sign in to comment.