Skip to content

Commit 38cd448

Browse files
committed
refactor(plot_config): Moving height and width specifications into constants at top of Adstock and Saturation files, so the plot sizes are set programmatically
1 parent 0fb5146 commit 38cd448

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

streamlit/mmm-explainer/pages/Adstock.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
weibull_adstock,
2424
)
2525

26+
# Constants
27+
PLOT_HEIGHT = 600
28+
PLOT_WIDTH = 1000
29+
30+
2631
# -------------------------- TOP OF PAGE INFORMATION -------------------------
2732

2833
# Set browser / tab config
@@ -177,8 +182,8 @@
177182
},
178183
)
179184
# Format plot
180-
fig.layout.height = 600
181-
fig.layout.width = 1000
185+
fig.layout.height = PLOT_HEIGHT
186+
fig.layout.width = PLOT_WIDTH
182187
fig.update_layout(
183188
title_text="Geometric Adstock Decayed Over Weeks", title_font=dict(size=30)
184189
)
@@ -345,8 +350,8 @@
345350
},
346351
)
347352
# Format plot
348-
fig.layout.height = 600
349-
fig.layout.width = 1000
353+
fig.layout.height = PLOT_HEIGHT
354+
fig.layout.width = PLOT_WIDTH
350355
fig.update_layout(
351356
title_text="Geometric Adstock Decayed Over Weeks", title_font=dict(size=30)
352357
)
@@ -493,8 +498,8 @@
493498
color_discrete_map={"Line A": "#636EFA", "Line B": "#EF553B"},
494499
)
495500
# Format plot
496-
fig.layout.height = 600
497-
fig.layout.width = 1000
501+
fig.layout.height = PLOT_HEIGHT
502+
fig.layout.width = PLOT_WIDTH
498503
fig.update_layout(
499504
title_text="Weibull CDF Adstock Decayed Over Weeks", title_font=dict(size=30)
500505
)
@@ -645,8 +650,8 @@
645650
color_discrete_map={"Line A": "#636EFA", "Line B": "#EF553B"},
646651
)
647652
# Format plot
648-
fig.layout.height = 600
649-
fig.layout.width = 1000
653+
fig.layout.height = PLOT_HEIGHT
654+
fig.layout.width = PLOT_WIDTH
650655
fig.update_layout(
651656
title_text="Weibull PDF Adstock Decayed Over Weeks", title_font=dict(size=30)
652657
)

streamlit/mmm-explainer/pages/Saturation.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
tanh_saturation,
2424
)
2525

26+
# Constants
27+
PLOT_HEIGHT = 500
28+
PLOT_WIDTH = 1000
29+
2630
# -------------------------- TOP OF PAGE INFORMATION -------------------------
2731

2832
# Set browser / tab config
@@ -131,8 +135,8 @@
131135
title_text="Logistic Saturation Curve",
132136
xaxis_title="Media Spend",
133137
yaxis_title="Conversions",
134-
height=500,
135-
width=1000,
138+
height=PLOT_HEIGHT,
139+
width=PLOT_WIDTH,
136140
)
137141

138142
st.plotly_chart(fig_root, use_container_width=True)
@@ -191,8 +195,8 @@
191195
title_text="Tanh Saturation Curve",
192196
xaxis_title="Media Spend",
193197
yaxis_title="Conversions",
194-
height=500,
195-
width=1000,
198+
height=PLOT_HEIGHT,
199+
width=PLOT_WIDTH,
196200
)
197201

198202
st.plotly_chart(fig_root, use_container_width=True)
@@ -251,8 +255,8 @@
251255
title_text="Michaelis-Menten Saturation Curve",
252256
xaxis_title="Media Spend",
253257
yaxis_title="Conversions",
254-
height=500,
255-
width=1000,
258+
height=PLOT_HEIGHT,
259+
width=PLOT_WIDTH,
256260
)
257261

258262
st.plotly_chart(fig_root, use_container_width=True)

0 commit comments

Comments
 (0)