Skip to content

Commit addcf71

Browse files
committed
Update main heatmap
1 parent afc317b commit addcf71

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

codeclash/analysis/viz/heatmap_win_rates.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from collections import defaultdict
55
from pathlib import Path
66

7-
import matplotlib.colors as mcolors
87
import matplotlib.pyplot as plt
98
import numpy as np
109
from tqdm import tqdm
1110

11+
from codeclash.analysis.viz.utils import FONT_BOLD, MODEL_TO_DISPLAY_NAME
1212
from codeclash.constants import LOCAL_LOG_DIR
1313

1414

@@ -44,7 +44,7 @@ def main(log_dir: Path):
4444

4545
# Build matrix
4646
models = sorted({m for pair in results.keys() for m in pair})
47-
clean_names = [m.split("/")[-1] for m in models]
47+
clean_names = [MODEL_TO_DISPLAY_NAME[m.split("/")[-1]] for m in models]
4848
n = len(models)
4949

5050
matrix = np.full((n, n), np.nan)
@@ -54,26 +54,34 @@ def main(log_dir: Path):
5454
matrix[i, j] = results[(m1, m2)][0] / results[(m1, m2)][1]
5555

5656
# Plot
57-
fig, ax = plt.subplots(figsize=(10, 8))
58-
cmap = mcolors.LinearSegmentedColormap.from_list("br", ["#3498db", "#ffffff", "#e74c3c"])
59-
60-
masked = np.ma.masked_where(np.isnan(matrix), matrix)
61-
im = ax.imshow(masked, cmap=cmap, vmin=0, vmax=1)
57+
FONT_BOLD.set_size(18)
58+
_, ax = plt.subplots(figsize=(10, 8))
59+
# cmap = mcolors.LinearSegmentedColormap.from_list("br", ["#e74c3c", "#ffffff", "#3498db"])
60+
# masked = np.ma.masked_where(np.isnan(matrix), matrix)
61+
# im = ax.imshow(masked, cmap=cmap, vmin=0, vmax=1)
6262

6363
# Add percentages
6464
for i in range(n):
6565
for j in range(n):
6666
if not np.isnan(matrix[i, j]):
6767
color = "white" if abs(matrix[i, j] - 0.5) > 0.3 else "black"
68-
ax.text(j, i, f"{matrix[i, j]:.0%}", ha="center", va="center", color=color, fontweight="bold")
68+
ax.text(
69+
j,
70+
i,
71+
f"{matrix[i, j]:.0%}",
72+
ha="center",
73+
va="center",
74+
color=color,
75+
fontweight="bold",
76+
fontproperties=FONT_BOLD,
77+
)
6978

7079
ax.set_xticks(range(n))
7180
ax.set_yticks(range(n))
72-
ax.set_xticklabels(clean_names, rotation=45, ha="right")
73-
ax.set_yticklabels(clean_names)
74-
ax.set_title("Model Win Rate Heatmap (Round Level)\n(Row beats Column)", fontsize=14, fontweight="bold")
81+
ax.set_xticklabels(clean_names, rotation=45, ha="right", fontproperties=FONT_BOLD)
82+
ax.set_yticklabels(clean_names, fontproperties=FONT_BOLD)
7583

76-
plt.colorbar(im, label="Win Rate")
84+
# plt.colorbar(im, label="Win Rate")
7785
plt.tight_layout()
7886
plt.savefig("heatmap_win_rates.png", dpi=300, bbox_inches="tight")
7987
print("Heatmap saved to heatmap_win_rates.png")

codeclash/analysis/viz/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import matplotlib.font_manager as fm
2+
3+
from codeclash import REPO_DIR
4+
5+
MODEL_TO_DISPLAY_NAME = {
6+
"claude-sonnet-4-20250514": "Claude Sonnet 4",
7+
"claude-sonnet-4-5-20250929": "Claude Sonnet 4.5",
8+
"grok-code-fast-1": "Grok Code Fast",
9+
"gemini-2.5-pro": "Gemini 2.5 Pro",
10+
"gpt-5": "GPT-5",
11+
"gpt-5-mini": "GPT-5 Mini",
12+
"qwen3-coder-plus-2025-09-23": "Qwen3 Coder",
13+
"o3": "o3",
14+
}
15+
16+
FONT_REG = fm.FontProperties(fname=REPO_DIR / "assets/texgyrepagella-regular.otf")
17+
FONT_BOLD = fm.FontProperties(fname=REPO_DIR / "assets/texgyrepagella-bold.otf")

0 commit comments

Comments
 (0)