Skip to content

Commit

Permalink
Add documentation notebook for slopes (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
GStechschulte authored Aug 10, 2023
1 parent 457eee3 commit fcf8ab5
Show file tree
Hide file tree
Showing 7 changed files with 2,522 additions and 24 deletions.
3 changes: 2 additions & 1 deletion bambi/plots/effects.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# pylint: disable=ungrouped-imports
from dataclasses import dataclass, field
import itertools
from typing import Dict, Union

import arviz as az
import numpy as np
import pandas as pd
import xarray as xr
from pandas.api.types import is_categorical_dtype, is_string_dtype
import xarray as xr

from bambi.models import Model
from bambi.plots.create_data import create_cap_data, create_differences_data
Expand Down
2 changes: 1 addition & 1 deletion bambi/plots/plot_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def plot_numeric(
ax = axes[0]
values_main = transform_main(plot_data[main])
ax.plot(values_main, y_hat_mean, solid_capstyle="butt", color="C0")
ax.fill_between(values_main, y_hat_bounds[0], y_hat_bounds[1], color="C0", alpha=0.4)
ax.fill_between(values_main, y_hat_bounds[0], y_hat_bounds[1], alpha=0.4)
elif "group" in covariates and not "panel" in covariates:
ax = axes[0]
colors = get_unique_levels(plot_data[color])
Expand Down
1 change: 0 additions & 1 deletion bambi/plots/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ def plot_slopes(

if conditional is None and average_by is None:
raise ValueError("Must specify at least one of 'conditional' or 'average_by'.")

if conditional is not None:
if not isinstance(conditional, str):
if len(conditional) > 3 and average_by is None:
Expand Down
1 change: 0 additions & 1 deletion bambi/plots/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def set_default_values(model: Model, data_dict: dict, kind: str) -> dict:
if not isinstance(value, (list, np.ndarray)):
data_dict[key] = [value]
return data_dict

return data_dict


Expand Down
3 changes: 2 additions & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Examples
notebooks/hsgp_1d
notebooks/hsgp_2d
notebooks/plot_cap
notebooks/plot_comparisons
notebooks/plot_comparisons
notebooks/plot_slopes
38 changes: 19 additions & 19 deletions docs/notebooks/plot_comparisons.ipynb

Large diffs are not rendered by default.

2,498 changes: 2,498 additions & 0 deletions docs/notebooks/plot_slopes.ipynb

Large diffs are not rendered by default.

0 comments on commit fcf8ab5

Please sign in to comment.