From bbf6a97151fd0c5cd2922aa0a299782611f1e3e2 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Thu, 11 Jun 2026 10:47:57 +0000 Subject: [PATCH] diag(#40): fix 3x2 plot -- keep bottom spine at axis edge (tick labels collided with rugs), skip labels on narrow zones Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com> --- scripts/diag_pinning.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/diag_pinning.py b/scripts/diag_pinning.py index 7605dc3..0ede543 100644 --- a/scripts/diag_pinning.py +++ b/scripts/diag_pinning.py @@ -280,11 +280,13 @@ def plot_q2(df: pl.DataFrame, k_mid: float, k_rout: float, subtitle: str, out_pn ax.plot(grid, yk, color=c, lw=lw, ls=ls) ymax *= 1.18 # rug of the ACTUAL live points (KDEs of n~20 are smooth fiction; the rout-tail - # precision claim rests on a handful of rollouts -- show them). hack row on top. + # precision claim rests on a handful of rollouts -- show them). hack row on top, + # in a strip below y=0 (faint separator line); tick labels stay outside the axes. + ax.axhline(0, color="#cccccc", lw=0.6, zorder=0) for row, (p, c) in enumerate((("on_hackpos", HACK), ("on_fail", FAIL), ("on_solve", SOLVE))): x = pops[p][col].to_numpy() ax.plot(x, np.full(len(x), -(0.035 + 0.035 * row) * ymax), "|", - color=c, ms=4, alpha=0.6, mew=0.8, clip_on=False) + color=c, ms=4, alpha=0.6, mew=0.8) # three zones: keep | absorb | rout ax.axvspan(t_lo, min(t_hi, hi), color=ABSORB_C, alpha=0.08, lw=0) @@ -292,17 +294,18 @@ def plot_q2(df: pl.DataFrame, k_mid: float, k_rout: float, subtitle: str, out_pn ax.axvline(t_lo, color=ABSORB_C, lw=1.2, ls="--") ax.axvline(t_hi, color=ROUT_C, lw=1.2, ls="--") ax.axvline(oracle, color=ORACLE, lw=1.3, ls="-.") - for xz, lab in ((min(t_lo, hi) - 0.02 * (hi - lo), "keep"), - ((t_lo + min(t_hi, hi)) / 2, "absorb"), - ((min(t_hi, hi) + hi) / 2, "rout")): - if lo < xz < hi: + # zone labels, skipping any whose zone is too narrow on this axis to label legibly + min_w = 0.05 * (hi - lo) + for xz, lab, w in ((min(t_lo, hi) - 0.04 * (hi - lo), "keep", min(t_lo, hi) - lo), + ((t_lo + min(t_hi, hi)) / 2, "absorb", min(t_hi, hi) - t_lo), + ((min(t_hi, hi) + hi) / 2, "rout", hi - min(t_hi, hi))): + if lo < xz < hi and w > min_w: ax.text(xz, ymax * 0.97, lab, ha="center", va="top", fontsize=7.5, color="#555555") ax.set_xlim(lo, hi) ax.set_ylim(-0.13 * ymax, ymax) # negative strip hosts the rugs ax.set_yticks([]) # KDE density units are meaningless ink for sp in ("top", "right", "left"): ax.spines[sp].set_visible(False) - ax.spines["bottom"].set_position(("data", 0)) ax.set_title(f"{rep} ยท {kind} AUROC={auroc_pos:.2f} (A>0 contrast; vs-all {auroc:.2f}) " f"P@rout={prec:.2f} (n={n_rout}) R={rec:.2f}", fontsize=9) ax.set_xlabel({"cos": "cosine to v (concat modules)",