Skip to content

Commit 7969a46

Browse files
committed
fix(benchmark): correct annotation label order and overlap in combined plots
Range labels now display min → max (ascending) and daily annotations are positioned below the line to prevent overlap with hourly labels.
1 parent f433566 commit 7969a46

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

benchmark/bear/analyze_combined.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _plot_line(ax: Axes, pct: list[float], vals: list[float], style_key: str) ->
7272

7373

7474
def _annotate_line_range(ax: Axes, pct: list[float], vals: list[float], color: str,
75-
x_pos: float | None = None) -> None:
75+
x_pos: float | None = None, below: bool = False) -> None:
7676
min_val = min(vals)
7777
max_val = max(vals)
7878
if x_pos is not None:
@@ -81,9 +81,12 @@ def _annotate_line_range(ax: Axes, pct: list[float], vals: list[float], color: s
8181
else:
8282
closest_idx = len(vals) // 2
8383
y_val = vals[closest_idx]
84-
label = f"{_format_ms_label(max_val)} \u2192 {_format_ms_label(min_val)}"
85-
ax.annotate(label, xy=(pct[closest_idx], y_val), fontsize=8, color=color,
86-
ha="center", va="bottom")
84+
label = f"{_format_ms_label(min_val)} \u2192 {_format_ms_label(max_val)}"
85+
offset = (0, -6) if below else (0, 4)
86+
va = "top" if below else "bottom"
87+
ax.annotate(label, xy=(pct[closest_idx], y_val), xytext=offset,
88+
textcoords="offset points", fontsize=8, color=color,
89+
ha="center", va=va)
8790

8891

8992
def _plot_line_chart(ax: Axes,
@@ -95,7 +98,7 @@ def _plot_line_chart(ax: Axes,
9598
pct_d, vals_d = _normalize_keys(daily_data)
9699
pct_h, vals_h = _normalize_keys(hourly_data)
97100
_plot_line(ax, pct_d, vals_d, "tal_daily")
98-
_annotate_line_range(ax, pct_d, vals_d, STYLES["tal_daily"]["color"], x_pos=20)
101+
_annotate_line_range(ax, pct_d, vals_d, STYLES["tal_daily"]["color"], x_pos=20, below=True)
99102
_plot_line(ax, pct_h, vals_h, "tal_hourly")
100103
_annotate_line_range(ax, pct_h, vals_h, STYLES["tal_hourly"]["color"], x_pos=75)
101104
if daily_ost_data:

0 commit comments

Comments
 (0)