"""Matplotlib style for WP31 figures: validated categorical palette (dataviz skill reference instance), thin marks, recessive axes, one y-axis per panel, direct labels where few series.""" import matplotlib as mpl import matplotlib.pyplot as plt CAT = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6", "#e34948"] # fixed order SEQ_BLUE = ["#cde2fb", "#9ec5f4", "#6da7ec", "#3987e5", "#256abf", "#184f95", "#0d366b"] TEXT, TEXT2, GRID = "#0b0b0b", "#52514e", "#e6e5e1" def setup(): mpl.rcParams.update({ "figure.dpi": 150, "savefig.dpi": 300, "font.size": 8, "axes.titlesize": 8.5, "axes.labelsize": 8, "legend.fontsize": 7, "xtick.labelsize": 7, "ytick.labelsize": 7, "axes.edgecolor": GRID, "axes.linewidth": 0.6, "axes.grid": True, "grid.color": GRID, "grid.linewidth": 0.5, "axes.spines.top": False, "axes.spines.right": False, "lines.linewidth": 1.4, "lines.markersize": 4, "text.color": TEXT, "axes.labelcolor": TEXT2, "xtick.color": TEXT2, "ytick.color": TEXT2, "legend.frameon": False, "axes.prop_cycle": mpl.cycler(color=CAT), "pdf.fonttype": 42, "font.family": "DejaVu Sans", }) def save(fig, name, outdir="results/figures"): import os os.makedirs(outdir, exist_ok=True) for ext in ("pdf", "png"): fig.savefig(f"{outdir}/{name}.{ext}", bbox_inches="tight") plt.close(fig) return f"{outdir}/{name}.pdf"