Scientific Figure Pro
Use the helpers in scripts/scientific_figure_pro.py to keep figure style consistent across tasks.
Apply Style
- Import and call
apply_publication_style(...) first.
- Choose scale:
- Use
FigureStyle(font_size=24, axes_linewidth=3) for dense bar/comparison panels.
- Use
FigureStyle(font_size=15 or 16, axes_linewidth=2) for compact trend/scatter plots.
- Keep
text.usetex=False unless math typography is required and TeX is installed.
Use High-Level Plot Functions
make_grouped_bar(ax, categories, series, labels, ...)
annotate_bars(ax, bars, fontsize=12): Add exact values above bars.
make_trend(ax, x, y_series, labels, ...)
make_scatter(ax, x, y, groups=..., labels=...)
make_sphere_illustration(ax, light_dir=...): Create a shaded 3D-effect sphere.
finalize_figure(fig, out_path, dpi=300, pad=2)
These encode the house defaults:
- Ultra-Wide Scaling: Use wide
figsize (e.g., width 3-4x height) for multi-metric panels.
- Legend Isolation: Consider dedicating the last axis in a grid to a shared legend (
ax.set_axis_off()).
- Precision Ticks: Use
FixedLocator for clean, whole-number y-ticks.
- Top/right spines removed
- Frameless legends
- Explicit y-limits with modest headroom
- Black bar edges for print-safe contrast
- Repository-aligned color palette
Reproducible Export Rules
- Default to
dpi=300.
- Use
dpi=600 for dense bar-heavy panels with small text.
- Always call
finalize_figure(...) to enforce tight_layout(pad=2) before saving.
Palette Policy
Use semantic colors from PALETTE:
- Blues (
blue_main, blue_secondary) for key/proposed methods.
- Greens (
green_1..green_3) for positive/improvement variants.
- Reds (
red_1, red_2, red_strong) for contrasting baselines/ablations.
neutral for references/background categories.
highlight only for targeted callouts.
Quick Start
import importlib.util
from pathlib import Path
import sys
module_path = Path("skills/scientific-figure-pro/scripts/scientific_figure_pro.py")
spec = importlib.util.spec_from_file_location("scientific_figure_pro", module_path)
mod = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = mod
spec.loader.exec_module(mod)
mod.apply_publication_style(mod.FigureStyle(font_size=16, axes_linewidth=2.5))
fig, ax = plt.subplots(figsize=(9, 5))
mod.make_grouped_bar(ax, categories, series, labels)
mod.finalize_figure(fig, "figure.png", dpi=300, pad=2)
If importing by package path is inconvenient, load the module by relative file path and reuse the same APIs.
1---2name: scientific-figure-pro3description: Generate publication-ready scientific figures in Python/matplotlib with a consistent house style (Helvetica/Arial-like sans fonts, high-contrast palettes, minimal spines, frameless legends, and tight export defaults). Use when creating bar, trend, scatter, or multi-panel academic figures that must match repository-style aesthetics and reproducibility constraints.4---56# Scientific Figure Pro78Use the helpers in `scripts/scientific_figure_pro.py` to keep figure style consistent across tasks.910## Apply Style11121. Import and call `apply_publication_style(...)` first.132. Choose scale:14- Use `FigureStyle(font_size=24, axes_linewidth=3)` for dense bar/comparison panels.15- Use `FigureStyle(font_size=15 or 16, axes_linewidth=2)` for compact trend/scatter plots.163. Keep `text.usetex=False` unless math typography is required and TeX is installed.1718## Use High-Level Plot Functions1920- `make_grouped_bar(ax, categories, series, labels, ...)`21- `annotate_bars(ax, bars, fontsize=12)`: Add exact values above bars.22- `make_trend(ax, x, y_series, labels, ...)`23- `make_scatter(ax, x, y, groups=..., labels=...)`24- `make_sphere_illustration(ax, light_dir=...)`: Create a shaded 3D-effect sphere.25- `finalize_figure(fig, out_path, dpi=300, pad=2)`2627These encode the house defaults:2829- **Ultra-Wide Scaling:** Use wide `figsize` (e.g., width 3-4x height) for multi-metric panels.30- **Legend Isolation:** Consider dedicating the last axis in a grid to a shared legend (`ax.set_axis_off()`).31- **Precision Ticks:** Use `FixedLocator` for clean, whole-number y-ticks.32- **Top/right spines removed**33- **Frameless legends**34- **Explicit y-limits with modest headroom**35- **Black bar edges for print-safe contrast**36- **Repository-aligned color palette**3738## Reproducible Export Rules39401. Default to `dpi=300`.412. Use `dpi=600` for dense bar-heavy panels with small text.423. Always call `finalize_figure(...)` to enforce `tight_layout(pad=2)` before saving.4344## Palette Policy4546Use semantic colors from `PALETTE`:4748- Blues (`blue_main`, `blue_secondary`) for key/proposed methods.49- Greens (`green_1..green_3`) for positive/improvement variants.50- Reds (`red_1`, `red_2`, `red_strong`) for contrasting baselines/ablations.51- `neutral` for references/background categories.52- `highlight` only for targeted callouts.5354## Quick Start5556```python57import importlib.util58from pathlib import Path59import sys6061module_path = Path("skills/scientific-figure-pro/scripts/scientific_figure_pro.py")62spec = importlib.util.spec_from_file_location("scientific_figure_pro", module_path)63mod = importlib.util.module_from_spec(spec)64sys.modules[spec.name] = mod65spec.loader.exec_module(mod)6667mod.apply_publication_style(mod.FigureStyle(font_size=16, axes_linewidth=2.5))68fig, ax = plt.subplots(figsize=(9, 5))69mod.make_grouped_bar(ax, categories, series, labels)70mod.finalize_figure(fig, "figure.png", dpi=300, pad=2)71```7273If importing by package path is inconvenient, load the module by relative file path and reuse the same APIs.