"""SCI Figure Hub — Publication Precision-Recall & Reliability Calibration Dual Panel (CC0-1.0)""" import numpy as np import matplotlib.pyplot as plt PALETTE = ["#E64B35", "#00A087", "#3C5488"] plt.rcParams.update({ "font.family": "sans-serif", "font.sans-serif": ["Arial", "Helvetica", "DejaVu Sans"], "font.size": 8, "axes.linewidth": 0.8, "axes.spines.top": False, "axes.spines.right": False, "pdf.fonttype": 42, }) rec = np.linspace(0.02, 1.0, 120) bins = np.linspace(0.08, 0.92, 9) fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6.4, 2.6), dpi=300) pr_specs = [ ("Ours (AP=0.91)", 1.0 - 0.14 * rec**2.4, bins * 0.98 + 0.01), ("ResNet (AP=0.82)", 1.0 - 0.30 * rec**1.9, bins * 0.86 + 0.09), ("MLP (AP=0.71)", 0.95 - 0.48 * rec**1.5, bins * 0.74 + 0.16), ] for idx, (lbl, prec, cal) in enumerate(pr_specs): col = PALETTE[idx % len(PALETTE)] ax1.plot(rec, np.clip(prec, 0.12, 1.0), color=col, lw=1.6, label=lbl) ax2.plot(bins, cal, "-o", color=col, lw=1.4, ms=3.5, label=lbl.split(" ")[0]) ax1.axhline(0.15, color="#94A3B8", ls="--", lw=0.8) ax1.set_xlabel("Recall") ax1.set_ylabel("Precision") ax1.set_ylim(0, 1.04) ax1.legend(frameon=False, fontsize=6.8, loc="lower left") ax2.plot([0, 1], [0, 1], "--", color="#64748B", lw=0.9, label="Perfect") ax2.set_xlabel("Mean Predicted Probability") ax2.set_ylabel("Observed Fraction of Positives") ax2.legend(frameon=False, fontsize=6.8, loc="upper left") fig.tight_layout() fig.savefig("pr_calibration_dual.pdf", bbox_inches="tight")