Spaces:
Sleeping
Sleeping
Fix Plotly rendering: stronger line widths, white bg, Streamlit theme, NaN-safe arrays
Browse files
app.py
CHANGED
|
@@ -259,7 +259,7 @@ def with_quota(alpha_d: float, beta_d: float, gamma_d: float,
|
|
| 259 |
# ----------------------------
|
| 260 |
|
| 261 |
def add_line(fig: go.Figure, q: np.ndarray, p: np.ndarray, name: str, color: str, dash: str = "solid") -> None:
|
| 262 |
-
fig.add_trace(go.Scatter(x=q, y=p, mode="lines", name=name, line=dict(color=color, dash=dash)))
|
| 263 |
|
| 264 |
|
| 265 |
def add_filled_area(
|
|
@@ -405,8 +405,8 @@ def main() -> None:
|
|
| 405 |
q_max = max(1.0, *[float(q) for q in q_candidates if np.isfinite(q)]) * 1.2
|
| 406 |
|
| 407 |
q = np.linspace(0.0, q_max, 400)
|
| 408 |
-
p_d = demand_price(q, alpha_d, beta_d, gamma_d)
|
| 409 |
-
p_s = supply_price(q, alpha_s, beta_s, gamma_s)
|
| 410 |
|
| 411 |
fig = go.Figure()
|
| 412 |
add_line(fig, q, p_d, name="Demand", color="#1f77b4")
|
|
@@ -490,7 +490,8 @@ def main() -> None:
|
|
| 490 |
yaxis_title="Price (P)",
|
| 491 |
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="left", x=0),
|
| 492 |
margin=dict(l=20, r=20, t=20, b=20),
|
| 493 |
-
|
|
|
|
| 494 |
height=560,
|
| 495 |
)
|
| 496 |
|
|
@@ -499,7 +500,7 @@ def main() -> None:
|
|
| 499 |
p_max = max(10.0, *[float(p) for p in p_candidates if np.isfinite(p)]) * 1.05
|
| 500 |
fig.update_yaxes(range=[0, p_max])
|
| 501 |
|
| 502 |
-
st.plotly_chart(fig, use_container_width=True)
|
| 503 |
|
| 504 |
# ----------------------------
|
| 505 |
# Downloads
|
|
|
|
| 259 |
# ----------------------------
|
| 260 |
|
| 261 |
def add_line(fig: go.Figure, q: np.ndarray, p: np.ndarray, name: str, color: str, dash: str = "solid") -> None:
|
| 262 |
+
fig.add_trace(go.Scatter(x=q, y=p, mode="lines", name=name, line=dict(color=color, dash=dash, width=2)))
|
| 263 |
|
| 264 |
|
| 265 |
def add_filled_area(
|
|
|
|
| 405 |
q_max = max(1.0, *[float(q) for q in q_candidates if np.isfinite(q)]) * 1.2
|
| 406 |
|
| 407 |
q = np.linspace(0.0, q_max, 400)
|
| 408 |
+
p_d = np.nan_to_num(demand_price(q, alpha_d, beta_d, gamma_d), nan=0.0, posinf=0.0, neginf=0.0)
|
| 409 |
+
p_s = np.nan_to_num(supply_price(q, alpha_s, beta_s, gamma_s), nan=0.0, posinf=0.0, neginf=0.0)
|
| 410 |
|
| 411 |
fig = go.Figure()
|
| 412 |
add_line(fig, q, p_d, name="Demand", color="#1f77b4")
|
|
|
|
| 490 |
yaxis_title="Price (P)",
|
| 491 |
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="left", x=0),
|
| 492 |
margin=dict(l=20, r=20, t=20, b=20),
|
| 493 |
+
paper_bgcolor="white",
|
| 494 |
+
plot_bgcolor="white",
|
| 495 |
height=560,
|
| 496 |
)
|
| 497 |
|
|
|
|
| 500 |
p_max = max(10.0, *[float(p) for p in p_candidates if np.isfinite(p)]) * 1.05
|
| 501 |
fig.update_yaxes(range=[0, p_max])
|
| 502 |
|
| 503 |
+
st.plotly_chart(fig, use_container_width=True, theme="streamlit")
|
| 504 |
|
| 505 |
# ----------------------------
|
| 506 |
# Downloads
|