Update app.py
Browse files
app.py
CHANGED
|
@@ -18,24 +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=(
|
| 22 |
-
# Traffic light backgrounds
|
| 23 |
-
ax.axhspan(0, 0.6, color="#FF4D4F", alpha=0.
|
| 24 |
-
ax.axhspan(0.6, 0.8, color="#FFE58F", alpha=0.
|
| 25 |
-
ax.axhspan(0.8, 1, color="#52C41A", alpha=0.
|
| 26 |
-
# Value marker
|
| 27 |
-
ax.axhline(value, color='black', lw=
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
ax.set_xlim(0, 1)
|
| 31 |
ax.set_ylim(0, 1)
|
| 32 |
ax.set_xticks([])
|
| 33 |
ax.set_yticks([0, 0.6, 0.8, 1])
|
| 34 |
-
ax.set_yticklabels(["0.0", "0.6", "0.8", "1.0"])
|
| 35 |
-
|
| 36 |
-
ax.spines
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
return fig
|
| 38 |
|
|
|
|
| 39 |
# --- Scenario selector callback ---
|
| 40 |
def show_plots(scenario):
|
| 41 |
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)) # MUCH taller!
|
| 22 |
+
# Traffic light backgrounds (now horizontal, for vertical bar)
|
| 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, 1, color="#52C41A", alpha=0.35)
|
| 26 |
+
# Value marker (black horizontal line)
|
| 27 |
+
ax.axhline(value, color='black', lw=6, xmin=0.20, xmax=0.80)
|
| 28 |
+
# Value text, bold, big, just right of line
|
| 29 |
+
ax.text(0.5, value, f"{value:.3f}", ha='center', va='bottom', fontsize=22, color='black', weight='bold')
|
| 30 |
+
# Make it look like a traffic light by hiding x-axis and thick y-axis ticks
|
| 31 |
ax.set_xlim(0, 1)
|
| 32 |
ax.set_ylim(0, 1)
|
| 33 |
ax.set_xticks([])
|
| 34 |
ax.set_yticks([0, 0.6, 0.8, 1])
|
| 35 |
+
ax.set_yticklabels(["0.0", "0.6", "0.8", "1.0"], fontsize=16)
|
| 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, bold, multiline
|
| 42 |
+
ax.set_title(
|
| 43 |
+
f"{dim_col.replace('_', ' ').title()}\n({scenario_map[scenario]})",
|
| 44 |
+
fontsize=15, weight='bold', pad=20
|
| 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)
|