"""Matplotlib style for the P2 figures: reference palette of the dataviz skill (light mode), checked with validate_palette. - Categorical (≤ 3 groups per figure): blue, orange, aqua — passes all-pairs (CVD ΔE ≥ 9.2); aqua is < 3:1, so always labelled directly. - Ordinal (drift factor c): a single blue hue, light → dark. - Diverging (M2/competitor ratio around 1): blue ↔ red, with a neutral grey midpoint. """ from __future__ import annotations import matplotlib as mpl from matplotlib.colors import LinearSegmentedColormap, TwoSlopeNorm SURFACE, INK, INK2, MUTED, GRID, AXIS = "#fcfcfb", "#0b0b0b", "#52514e", "#898781", "#e1e0d9", "#c3c2b7" BLUE, ORANGE, AQUA = "#2a78d6", "#eb6834", "#1baf7a" ORDINAL_BLUE = ["#86b6ef", "#2a78d6", "#104281"] GOOD, CRITICAL = "#0ca30c", "#d03b3b" DIVERGING = LinearSegmentedColormap.from_list( "blue_gray_red", ["#104281", "#2a78d6", "#86b6ef", "#f0efec", "#ec8a89", "#d23f3e", "#8f2626"]) def diverging_norm(vmin: float, vcenter: float, vmax: float) -> TwoSlopeNorm: return TwoSlopeNorm(vcenter, vmin, vmax) def apply() -> None: mpl.rcParams.update({ "figure.facecolor": SURFACE, "axes.facecolor": SURFACE, "savefig.facecolor": SURFACE, "axes.edgecolor": AXIS, "axes.labelcolor": INK2, "axes.titlecolor": INK, "text.color": INK, "axes.grid": True, "grid.color": GRID, "grid.linewidth": 0.6, "axes.axisbelow": True, "axes.spines.top": False, "axes.spines.right": False, "xtick.color": AXIS, "ytick.color": AXIS, "xtick.labelcolor": INK2, "ytick.labelcolor": INK2, "font.size": 9, "axes.titlesize": 10, "axes.titleweight": "regular", "axes.titlelocation": "left", "lines.linewidth": 1.5, "lines.markersize": 5, "legend.frameon": False, "legend.fontsize": 8, "axes.prop_cycle": mpl.cycler(color=[BLUE, ORANGE, AQUA]), })