Update app.py
Browse files
app.py
CHANGED
|
@@ -18,35 +18,35 @@ scenario_map = {"0": "No cleansing", "A": "Urgent cleansing", "B": "Urgent+Low u
|
|
| 18 |
# --- Traffic light plotting utility ---
|
| 19 |
def plot_dimension(dim_col, scenario):
|
| 20 |
value = data.set_index("scenario").loc[scenario, dim_col]
|
| 21 |
-
fig, ax = plt.subplots(figsize=(3, 6))
|
| 22 |
-
# Traffic light backgrounds
|
| 23 |
ax.axhspan(0, 0.6, color="#FF4D4F", alpha=0.35)
|
| 24 |
ax.axhspan(0.6, 0.8, color="#FFE58F", alpha=0.35)
|
| 25 |
-
ax.axhspan(0.8,
|
| 26 |
-
# Value marker (
|
| 27 |
-
ax.axhline(value, color='black', lw=
|
| 28 |
-
# Value text
|
| 29 |
-
ax.text(0.5, value, f"{value:.3f}", ha='center', va='bottom', fontsize=
|
| 30 |
-
#
|
| 31 |
ax.set_xlim(0, 1)
|
| 32 |
-
ax.set_ylim(0,
|
| 33 |
ax.set_xticks([])
|
| 34 |
-
ax.set_yticks([0, 0.6, 0.8,
|
| 35 |
-
ax.set_yticklabels(["0.0", "0.6", "0.8", "1.0"], fontsize=
|
| 36 |
-
# Only left spine visible, thicker
|
| 37 |
for spine in ax.spines.values():
|
| 38 |
spine.set_visible(False)
|
| 39 |
ax.spines['left'].set_visible(True)
|
| 40 |
ax.spines['left'].set_linewidth(2)
|
| 41 |
-
# Title
|
| 42 |
ax.set_title(
|
| 43 |
f"{dim_col.replace('_', ' ').title()}\n({scenario_map[scenario]})",
|
| 44 |
-
fontsize=
|
| 45 |
)
|
| 46 |
plt.tight_layout()
|
| 47 |
return fig
|
| 48 |
|
| 49 |
|
|
|
|
| 50 |
# --- Scenario selector callback ---
|
| 51 |
def show_plots(scenario):
|
| 52 |
fig1 = plot_dimension("consistency_score", scenario)
|
|
|
|
| 18 |
# --- Traffic light plotting utility ---
|
| 19 |
def plot_dimension(dim_col, scenario):
|
| 20 |
value = data.set_index("scenario").loc[scenario, dim_col]
|
| 21 |
+
fig, ax = plt.subplots(figsize=(3, 6))
|
| 22 |
+
# Traffic light backgrounds
|
| 23 |
ax.axhspan(0, 0.6, color="#FF4D4F", alpha=0.35)
|
| 24 |
ax.axhspan(0.6, 0.8, color="#FFE58F", alpha=0.35)
|
| 25 |
+
ax.axhspan(0.8, 0.95, color="#52C41A", alpha=0.35) # Now top at 0.95
|
| 26 |
+
# Value marker (smaller, thinner)
|
| 27 |
+
ax.axhline(value, color='black', lw=2, xmin=0.35, xmax=0.65)
|
| 28 |
+
# Value text
|
| 29 |
+
ax.text(0.5, value, f"{value:.3f}", ha='center', va='bottom', fontsize=19, color='black', weight='bold')
|
| 30 |
+
# Styling
|
| 31 |
ax.set_xlim(0, 1)
|
| 32 |
+
ax.set_ylim(0, 0.95)
|
| 33 |
ax.set_xticks([])
|
| 34 |
+
ax.set_yticks([0, 0.6, 0.8, 0.95])
|
| 35 |
+
ax.set_yticklabels(["0.0", "0.6", "0.8", "1.0"], fontsize=14)
|
|
|
|
| 36 |
for spine in ax.spines.values():
|
| 37 |
spine.set_visible(False)
|
| 38 |
ax.spines['left'].set_visible(True)
|
| 39 |
ax.spines['left'].set_linewidth(2)
|
| 40 |
+
# Title with smaller padding
|
| 41 |
ax.set_title(
|
| 42 |
f"{dim_col.replace('_', ' ').title()}\n({scenario_map[scenario]})",
|
| 43 |
+
fontsize=14, weight='bold', pad=6
|
| 44 |
)
|
| 45 |
plt.tight_layout()
|
| 46 |
return fig
|
| 47 |
|
| 48 |
|
| 49 |
+
|
| 50 |
# --- Scenario selector callback ---
|
| 51 |
def show_plots(scenario):
|
| 52 |
fig1 = plot_dimension("consistency_score", scenario)
|