SPB Git

spb/wp31_uqo

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

Theme