Skip to content

Commit 7807d09

Browse files
andre15silvaclaude
andcommitted
fix(paper): clean up heatmaps — pcolormesh, no grid lines, 0.5–1.0 scale
- Switch from imshow to pcolormesh for crisp cell borders with no interpolation - Disable grid on heatmap axes (global rcParam bled across cells) - Hide tick marks (cells are visually delimited by white edges) - Fix annotation coordinates for pcolormesh cell centres (+0.5 offset) - Update HEATMAP_VMIN/VMAX to 0.5/1.0 in paper/style.py - Colorbar ticks at 0.5, 0.625, 0.75, 0.875, 1.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bf0d905 commit 7807d09

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

paper/style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
# --- Heatmap ---
3636
HEATMAP_CMAP = "Blues"
37-
HEATMAP_VMIN = 0.55
38-
HEATMAP_VMAX = 0.85
37+
HEATMAP_VMIN = 0.5
38+
HEATMAP_VMAX = 1.0
3939

4040

4141
def apply() -> None:

run_paper_figures.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,33 +629,38 @@ def plot_auc_heatmap(
629629
out_dir.mkdir(parents=True, exist_ok=True)
630630

631631
fig, ax = plt.subplots(figsize=(_style.FULL_WIDTH, _style.FIG_HEIGHT_HEAT))
632-
norm = mcolors.Normalize(vmin=_style.HEATMAP_VMIN, vmax=_style.HEATMAP_VMAX)
633-
im = ax.imshow(grid, aspect="auto", cmap=_style.HEATMAP_CMAP,
634-
norm=norm, origin="lower")
632+
ax.grid(False) # override global rcParam — grid lines bleed over heatmap cells
635633

636-
ax.set_xticks(range(n_bins))
634+
norm = mcolors.Normalize(vmin=_style.HEATMAP_VMIN, vmax=_style.HEATMAP_VMAX)
635+
# pcolormesh gives crisp cell edges with no interpolation artefacts
636+
im = ax.pcolormesh(grid, cmap=_style.HEATMAP_CMAP, norm=norm,
637+
linewidth=0.5, edgecolors="white")
638+
639+
ax.set_xticks([i + 0.5 for i in range(n_bins)])
637640
ax.set_xticklabels(
638641
[f"{i/n_bins:.1f}{(i+1)/n_bins:.1f}" for i in range(n_bins)],
639642
rotation=40, ha="right",
640643
)
641-
ax.set_yticks(range(len(layers)))
644+
ax.set_yticks([i + 0.5 for i in range(len(layers))])
642645
ax.set_yticklabels([f"Layer {l}" for l in layers])
643646
ax.set_xlabel(x_label)
644647
ax.set_ylabel("Layer")
648+
ax.tick_params(length=0) # hide tick marks — cells are already delimited
645649

646650
model_key = run_id.replace("_shuffled", "").replace("_step_rel", "").replace("_pooled_bineval", "")
647651
probe_label = PROBE_LABELS.get(probe, probe)
648652
ax.set_title(f"{probe_label}{MODEL_LABELS.get(model_key, model_key)}")
649653

650654
cb = plt.colorbar(im, ax=ax, label="AUC-ROC")
655+
cb.set_ticks([0.5, 0.625, 0.75, 0.875, 1.0])
651656
cb.ax.tick_params(labelsize=8)
652657

653658
mid = (_style.HEATMAP_VMIN + _style.HEATMAP_VMAX) / 2
654659
for li in range(len(layers)):
655660
for bi in range(n_bins):
656661
v = grid[li, bi]
657662
if not math.isnan(v):
658-
ax.text(bi, li, f"{v:.2f}", ha="center", va="center",
663+
ax.text(bi + 0.5, li + 0.5, f"{v:.2f}", ha="center", va="center",
659664
fontsize=6.5, color="white" if v > mid else "black")
660665

661666
fname = f"{probe}_auc_heatmap{suffix}.pdf"

0 commit comments

Comments
 (0)