SPB Git

spb/wp25_uqo

Public
1.9 KB · 37 lines python
1"""Matplotlib style for the paper's vector figures (dataviz method: form first, color by job, validated palette).23Categorical hues in fixed order (validated reference palette, light mode): blue, orange, aqua, yellow, magenta,4green, violet, red. Sequential = one hue (blue ramp). Diverging = orange–gray–blue. Thin marks, recessive axes,5direct labels where ≤ 4 series, legend always for ≥ 2 series, one axis per panel (never dual axes).6"""7import matplotlib as mpl8import matplotlib.pyplot as plt9from matplotlib.colors import LinearSegmentedColormap1011CAT = ['#2a78d6', '#eb6834', '#1baf7a', '#eda100', '#e87ba4', '#008300', '#6250d6', '#e34948']12SEQ = LinearSegmentedColormap.from_list('age_seq', ['#cde2fb', '#86b6ef', '#3987e5', '#1c5cab', '#184f95'])13DIV = LinearSegmentedColormap.from_list('age_div', ['#eb6834', '#f0efec', '#2a78d6'])14GRID, AXIS, TEXT, TEXT2 = '#e1e0d9', '#c3c2b7', '#0b0b0b', '#52514e'151617def use():18    mpl.rcParams.update({19        'figure.figsize': (6.2, 3.6), 'figure.dpi': 120, 'savefig.dpi': 300, 'savefig.bbox': 'tight',20        'font.family': 'serif', 'font.size': 9, 'axes.titlesize': 9.5, 'axes.labelsize': 9,21        'axes.prop_cycle': mpl.cycler(color=CAT), 'axes.edgecolor': AXIS, 'axes.linewidth': 0.6,22        'axes.grid': True, 'grid.color': GRID, 'grid.linewidth': 0.5, 'axes.axisbelow': True,23        'axes.spines.top': False, 'axes.spines.right': False, 'xtick.color': TEXT2, 'ytick.color': TEXT2,24        'text.color': TEXT, 'axes.labelcolor': TEXT, 'lines.linewidth': 1.6, 'lines.markersize': 4.5,25        'legend.frameon': False, 'legend.fontsize': 8, 'pdf.fonttype': 42, 'ps.fonttype': 42,26    })272829def label_end(ax, x, y, text, color, dx=0.01, **kw):30    """Direct label at the end of a line (selective labelling)."""31    ax.annotate(text, (x, y), xytext=(4, 0), textcoords='offset points', color=color, va='center', fontsize=8, **kw)323334def save(fig, path):35    fig.savefig(path)36    plt.close(fig)37
Files · 2c7f64611b7e4e05b42b2c034a2fd9beb6d14a58
Menu

Theme