Skip to content

Commit

Permalink
refactor(plot_config): Moving height and width specifications into co…
Browse files Browse the repository at this point in the history
…nstants at top of Adstock and Saturation files, so the plot sizes are set programmatically
  • Loading branch information
louismagowan committed May 17, 2024
1 parent 0fb5146 commit 38cd448
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
21 changes: 13 additions & 8 deletions streamlit/mmm-explainer/pages/Adstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
weibull_adstock,
)

# Constants
PLOT_HEIGHT = 600
PLOT_WIDTH = 1000


# -------------------------- TOP OF PAGE INFORMATION -------------------------

# Set browser / tab config
Expand Down Expand Up @@ -177,8 +182,8 @@
},
)
# Format plot
fig.layout.height = 600
fig.layout.width = 1000
fig.layout.height = PLOT_HEIGHT
fig.layout.width = PLOT_WIDTH
fig.update_layout(
title_text="Geometric Adstock Decayed Over Weeks", title_font=dict(size=30)
)
Expand Down Expand Up @@ -345,8 +350,8 @@
},
)
# Format plot
fig.layout.height = 600
fig.layout.width = 1000
fig.layout.height = PLOT_HEIGHT
fig.layout.width = PLOT_WIDTH
fig.update_layout(
title_text="Geometric Adstock Decayed Over Weeks", title_font=dict(size=30)
)
Expand Down Expand Up @@ -493,8 +498,8 @@
color_discrete_map={"Line A": "#636EFA", "Line B": "#EF553B"},
)
# Format plot
fig.layout.height = 600
fig.layout.width = 1000
fig.layout.height = PLOT_HEIGHT
fig.layout.width = PLOT_WIDTH
fig.update_layout(
title_text="Weibull CDF Adstock Decayed Over Weeks", title_font=dict(size=30)
)
Expand Down Expand Up @@ -645,8 +650,8 @@
color_discrete_map={"Line A": "#636EFA", "Line B": "#EF553B"},
)
# Format plot
fig.layout.height = 600
fig.layout.width = 1000
fig.layout.height = PLOT_HEIGHT
fig.layout.width = PLOT_WIDTH
fig.update_layout(
title_text="Weibull PDF Adstock Decayed Over Weeks", title_font=dict(size=30)
)
Expand Down
16 changes: 10 additions & 6 deletions streamlit/mmm-explainer/pages/Saturation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
tanh_saturation,
)

# Constants
PLOT_HEIGHT = 500
PLOT_WIDTH = 1000

# -------------------------- TOP OF PAGE INFORMATION -------------------------

# Set browser / tab config
Expand Down Expand Up @@ -131,8 +135,8 @@
title_text="Logistic Saturation Curve",
xaxis_title="Media Spend",
yaxis_title="Conversions",
height=500,
width=1000,
height=PLOT_HEIGHT,
width=PLOT_WIDTH,
)

st.plotly_chart(fig_root, use_container_width=True)
Expand Down Expand Up @@ -191,8 +195,8 @@
title_text="Tanh Saturation Curve",
xaxis_title="Media Spend",
yaxis_title="Conversions",
height=500,
width=1000,
height=PLOT_HEIGHT,
width=PLOT_WIDTH,
)

st.plotly_chart(fig_root, use_container_width=True)
Expand Down Expand Up @@ -251,8 +255,8 @@
title_text="Michaelis-Menten Saturation Curve",
xaxis_title="Media Spend",
yaxis_title="Conversions",
height=500,
width=1000,
height=PLOT_HEIGHT,
width=PLOT_WIDTH,
)

st.plotly_chart(fig_root, use_container_width=True)

0 comments on commit 38cd448

Please sign in to comment.