Merge pull request #23 from redhat-et/fix/legend-placement
Browse filesFix legend overlap and improve leaderboard chart readability
- app.py +3 -0
- src/charts.py +11 -4
app.py
CHANGED
|
@@ -77,6 +77,9 @@ FORCE_DARK_MODE_HEAD = """
|
|
| 77 |
}
|
| 78 |
})();
|
| 79 |
</script>
|
|
|
|
|
|
|
|
|
|
| 80 |
"""
|
| 81 |
|
| 82 |
|
|
|
|
| 77 |
}
|
| 78 |
})();
|
| 79 |
</script>
|
| 80 |
+
<style>
|
| 81 |
+
.responsive-plot { overflow-x: auto; }
|
| 82 |
+
</style>
|
| 83 |
"""
|
| 84 |
|
| 85 |
|
src/charts.py
CHANGED
|
@@ -220,14 +220,18 @@ def apply_plot_theme(fig: Figure, background_name: str | None = DEFAULT_BACKGROU
|
|
| 220 |
plot_bgcolor=theme["plot_bgcolor"],
|
| 221 |
font={"color": theme["text_primary"]},
|
| 222 |
title={"font": {"color": theme["text_primary"]}},
|
| 223 |
-
|
|
|
|
| 224 |
legend={
|
| 225 |
"orientation": "h",
|
| 226 |
"yanchor": "top",
|
| 227 |
"y": 1,
|
|
|
|
| 228 |
"xanchor": "center",
|
| 229 |
"x": 0.5,
|
| 230 |
"font": {"color": theme["text_muted"]},
|
|
|
|
|
|
|
| 231 |
},
|
| 232 |
)
|
| 233 |
# Remove fixed dimensions so Gradio/Plotly can size to the browser/container.
|
|
@@ -308,13 +312,16 @@ def create_leaderboard_benchmark_plot(
|
|
| 308 |
|
| 309 |
fig.update_layout(
|
| 310 |
title=None,
|
| 311 |
-
xaxis={"title": "Model / Harness", "categoryorder": "
|
| 312 |
-
yaxis={"title": "Score (%)", "range": [0,
|
| 313 |
legend_title_text=color_by,
|
| 314 |
bargap=0.28,
|
| 315 |
)
|
| 316 |
fig.update_xaxes(tickangle=-28)
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
| 318 |
|
| 319 |
|
| 320 |
def create_score_vs_cost_plot(
|
|
|
|
| 220 |
plot_bgcolor=theme["plot_bgcolor"],
|
| 221 |
font={"color": theme["text_primary"]},
|
| 222 |
title={"font": {"color": theme["text_primary"]}},
|
| 223 |
+
showlegend=True,
|
| 224 |
+
margin={"t": 60, "b": 0, "l": 0, "r": 0},
|
| 225 |
legend={
|
| 226 |
"orientation": "h",
|
| 227 |
"yanchor": "top",
|
| 228 |
"y": 1,
|
| 229 |
+
"yref": "container",
|
| 230 |
"xanchor": "center",
|
| 231 |
"x": 0.5,
|
| 232 |
"font": {"color": theme["text_muted"]},
|
| 233 |
+
"itemclick": False,
|
| 234 |
+
"itemdoubleclick": False,
|
| 235 |
},
|
| 236 |
)
|
| 237 |
# Remove fixed dimensions so Gradio/Plotly can size to the browser/container.
|
|
|
|
| 312 |
|
| 313 |
fig.update_layout(
|
| 314 |
title=None,
|
| 315 |
+
xaxis={"title": "Model / Harness", "categoryorder": "total descending"},
|
| 316 |
+
yaxis={"title": "Score (%)", "range": [0, plot_df["Score"].max() * 1.12]},
|
| 317 |
legend_title_text=color_by,
|
| 318 |
bargap=0.28,
|
| 319 |
)
|
| 320 |
fig.update_xaxes(tickangle=-28)
|
| 321 |
+
fig = apply_plot_theme(fig, background_name)
|
| 322 |
+
min_width = max(600, len(plot_df) * 80)
|
| 323 |
+
fig.update_layout(width=min_width)
|
| 324 |
+
return fig
|
| 325 |
|
| 326 |
|
| 327 |
def create_score_vs_cost_plot(
|