Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -240,6 +240,17 @@ def add_hline_safe(fig, y, **kwargs):
|
|
| 240 |
base.update(_clean_shape_kwargs(kwargs))
|
| 241 |
return fig.add_shape(**base)
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def add_vrect_safe(fig, x0, x1, **kwargs):
|
| 244 |
"""
|
| 245 |
add_vrect 대체: x0shift/x1shift를 값에 반영 후 제거하고,
|
|
@@ -1921,7 +1932,7 @@ def compare_distribution_figure(df_master, seg, mod, loy, stage_label):
|
|
| 1921 |
if loy == "ALL": candidates.append("loyalty")
|
| 1922 |
|
| 1923 |
key = None
|
| 1924 |
-
for k in candidates:
|
| 1925 |
if k in df_master.columns and df_master[k].astype(str).nunique(dropna=True) > 1:
|
| 1926 |
key = k
|
| 1927 |
break
|
|
@@ -1998,7 +2009,15 @@ def compare_distribution_figure(df_master, seg, mod, loy, stage_label):
|
|
| 1998 |
paper_bgcolor="#ffffff", plot_bgcolor="#ffffff"
|
| 1999 |
)
|
| 2000 |
|
| 2001 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2002 |
|
| 2003 |
def bubble_figure(
|
| 2004 |
df_scope: pd.DataFrame,
|
|
@@ -2170,7 +2189,12 @@ def bubble_figure(
|
|
| 2170 |
font=dict(size=12)
|
| 2171 |
)
|
| 2172 |
|
| 2173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2174 |
|
| 2175 |
def ppc_purchase_overlay_figure(row: pd.Series, m: int | None = None, draws: int = 6000) -> go.Figure:
|
| 2176 |
"""관측 구매율과 Posterior(베타) & Posterior Predictive(베타-이항) 오버레이."""
|
|
|
|
| 240 |
base.update(_clean_shape_kwargs(kwargs))
|
| 241 |
return fig.add_shape(**base)
|
| 242 |
|
| 243 |
+
def _pad_top(fig, px=40):
|
| 244 |
+
# 기존 margin 유지 + top만 늘림
|
| 245 |
+
m = fig.layout.margin or {}
|
| 246 |
+
fig.update_layout(margin=dict(
|
| 247 |
+
l=int(getattr(m, "l", 10) or 10),
|
| 248 |
+
r=int(getattr(m, "r", 10) or 10),
|
| 249 |
+
b=int(getattr(m, "b", 10) or 10),
|
| 250 |
+
t=int(getattr(m, "t", 0) or 0) + int(px),
|
| 251 |
+
))
|
| 252 |
+
return fig
|
| 253 |
+
|
| 254 |
def add_vrect_safe(fig, x0, x1, **kwargs):
|
| 255 |
"""
|
| 256 |
add_vrect 대체: x0shift/x1shift를 값에 반영 후 제거하고,
|
|
|
|
| 1932 |
if loy == "ALL": candidates.append("loyalty")
|
| 1933 |
|
| 1934 |
key = None
|
| 1935 |
+
for k in candidates:
|
| 1936 |
if k in df_master.columns and df_master[k].astype(str).nunique(dropna=True) > 1:
|
| 1937 |
key = k
|
| 1938 |
break
|
|
|
|
| 2009 |
paper_bgcolor="#ffffff", plot_bgcolor="#ffffff"
|
| 2010 |
)
|
| 2011 |
|
| 2012 |
+
# 공통 스타일 먼저
|
| 2013 |
+
fig = apply_dense_grid(fig)
|
| 2014 |
+
|
| 2015 |
+
# 3) 위로 들러붙는 것 방지용으로 '위 여백+도메인' 덮어쓰기
|
| 2016 |
+
fig.update_layout(margin=dict(l=10, r=10, t=68, b=28))
|
| 2017 |
+
fig.update_yaxes(domain=[0.0, 0.86]) # 위쪽 14% 비워서 아래로 내림
|
| 2018 |
+
|
| 2019 |
+
# 4) 리턴
|
| 2020 |
+
return fig
|
| 2021 |
|
| 2022 |
def bubble_figure(
|
| 2023 |
df_scope: pd.DataFrame,
|
|
|
|
| 2189 |
font=dict(size=12)
|
| 2190 |
)
|
| 2191 |
|
| 2192 |
+
# ▼ 추가: 위 공간 확보
|
| 2193 |
+
fig.update_layout(margin=dict(l=10, r=10, t=72, b=52), showlegend=False)
|
| 2194 |
+
fig.update_yaxes(domain=[0.0, 0.85])
|
| 2195 |
+
|
| 2196 |
+
# x축 제목 annotation 그대로 두면 됩니다
|
| 2197 |
+
return fig
|
| 2198 |
|
| 2199 |
def ppc_purchase_overlay_figure(row: pd.Series, m: int | None = None, draws: int = 6000) -> go.Figure:
|
| 2200 |
"""관측 구매율과 Posterior(베타) & Posterior Predictive(베타-이항) 오버레이."""
|