Skip to content

Commit bd3300c

Browse files
committed
improve plotting of adstock functions
1 parent 97e5bc9 commit bd3300c

File tree

2 files changed

+92
-256
lines changed

2 files changed

+92
-256
lines changed

causalpy/experiments/graded_intervention_its.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -919,25 +919,35 @@ def plot_transforms(
919919
if true_adstock_params.get("normalize", True):
920920
true_weights = true_weights / true_weights.sum()
921921

922-
width = 0.35
923-
ax.bar(
924-
lags - width / 2,
922+
# Line plot instead of bars
923+
ax.plot(
924+
lags,
925925
true_weights,
926-
width,
927-
alpha=0.8,
926+
"k--",
927+
linewidth=2.5,
928928
label="True",
929-
color="gray",
929+
alpha=0.8,
930930
)
931-
ax.bar(
932-
lags + width / 2,
931+
932+
# Estimated adstock line
933+
ax.plot(
934+
lags,
933935
est_weights,
934-
width,
935-
alpha=0.8,
936+
"C0-",
937+
linewidth=2.5,
936938
label="Estimated",
937-
color="C0",
939+
alpha=0.8,
938940
)
939941
else:
940-
ax.bar(lags, est_weights, alpha=0.7, color="C0", label="Estimated")
942+
# Single line for estimated only
943+
ax.plot(
944+
lags,
945+
est_weights,
946+
"C0-",
947+
linewidth=2.5,
948+
label="Estimated",
949+
alpha=0.8,
950+
)
941951

942952
ax.set_xlabel("Lag (periods)", fontsize=11)
943953
ax.set_ylabel("Adstock Weight", fontsize=11)

docs/source/notebooks/graded_intervention_time_series_single_channel_ols.ipynb

Lines changed: 70 additions & 244 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)