Download figures_paper/scripts/style.py from NLP-beginner/cs3319-project2: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/NLP-beginner/cs3319-project2/resolve/main/figures_paper/scripts/style.py
- Command line
-
hf download hf://NLP-beginner/cs3319-project2/figures_paper/scripts/style.py
-
curl -L -o style.py https://huggingface.co/NLP-beginner/cs3319-project2/resolve/main/figures_paper/scripts/style.py
2.04 kB
| """Shared ACM double-column paper style for the figures_paper package. | |
| Column widths follow ACM sigconf: single-column 3.25 in, double-column 6.75 in. | |
| Fonts tuned for two-column legibility. pdf.fonttype=42 embeds TrueType (venue-safe). | |
| """ | |
| from pathlib import Path | |
| import matplotlib as mpl | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| COL1 = 3.25 # single-column | |
| COL2 = 6.75 # double-column | |
| # Colorblind-safe + print-friendly. ``deep`` is the primary, ``muted`` secondary. | |
| PALETTE = list(sns.color_palette("deep")) | |
| MUTED = list(sns.color_palette("muted")) | |
| COLORBLIND = list(sns.color_palette("colorblind")) | |
| def apply(): | |
| sns.set_theme(style="whitegrid", context="paper", font_scale=1.0) | |
| mpl.rcParams.update({ | |
| "font.size": 8.5, | |
| "axes.labelsize": 9.0, | |
| "axes.titlesize": 9.5, | |
| "axes.titleweight": "bold", | |
| "xtick.labelsize": 8.0, | |
| "ytick.labelsize": 8.0, | |
| "legend.fontsize": 7.5, | |
| "legend.frameon": False, | |
| "figure.dpi": 150, | |
| "savefig.dpi": 300, | |
| "savefig.format": "pdf", | |
| "savefig.bbox": "tight", | |
| "savefig.pad_inches": 0.02, | |
| "pdf.fonttype": 42, | |
| "ps.fonttype": 42, | |
| "font.family": "DejaVu Sans", | |
| "axes.spines.top": False, | |
| "axes.spines.right": False, | |
| "axes.grid": True, | |
| "grid.alpha": 0.35, | |
| "grid.linewidth": 0.5, | |
| "lines.linewidth": 1.6, | |
| }) | |
| def ensure_dirs(root): | |
| root = Path(root) | |
| out = {} | |
| for sub in ("pdf", "png", "svg", "data"): | |
| d = root / "figures_paper" / sub | |
| d.mkdir(parents=True, exist_ok=True) | |
| out[sub] = d | |
| return out | |
| def save(fig, name, out): | |
| """Write PDF (vector), PNG (300 dpi preview), SVG. Closes the figure.""" | |
| fig.savefig(out["pdf"] / f"{name}.pdf") | |
| fig.savefig(out["png"] / f"{name}.png", dpi=300) | |
| fig.savefig(out["svg"] / f"{name}.svg") | |
| plt.close(fig) | |
| def stat_box(ax, x, y, s, fs=8): | |
| ax.text(x, y, s, transform=ax.transAxes, fontsize=fs, color="dimgray") | |