scientific-figure-pro

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scientific Figure Pro

科学图表生成工具(Scientific Figure Pro)

Use this skill to create or revise publication figures with consistent aesthetics from the figures4papers project.
使用此技能,可借助figures4papers项目的统一视觉风格,创建或修改可用于出版的图表。

Workflow

工作流程

  1. Identify the figure family (bar, trend, heatmap, scatter, multi-panel, conceptual illustration).
  2. Load helper APIs from
    scripts/scientific_figure_pro.py
    .
  3. Apply style first with
    apply_publication_style(...)
    .
  4. Build the figure using
    make_*
    helpers.
  5. Export with
    finalize_figure(...)
    to keep layout and output defaults consistent.
  1. 确定图表类型(条形图、趋势图、热图、散点图、多面板图、概念示意图)。
  2. scripts/scientific_figure_pro.py
    加载辅助API。
  3. 首先使用
    apply_publication_style(...)
    应用出版风格。
  4. 使用
    make_*
    系列辅助函数构建图表。
  5. 通过
    finalize_figure(...)
    导出,确保布局和输出默认设置一致。

Use The Helper Module

使用辅助模块

Load by file path when package imports are inconvenient:
python
import importlib.util
from pathlib import Path
import matplotlib.pyplot as plt

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)
spec.loader.exec_module(mod)
当无法通过包导入时,可通过文件路径加载:
python
import importlib.util
from pathlib import Path
import matplotlib.pyplot as plt

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)
spec.loader.exec_module(mod)

Core APIs

核心API

  • FigureStyle(...)
    : Configure typography and axis linewidth.
  • apply_publication_style(style=None)
    : Apply global rcParams.
  • create_subplots(nrows, ncols, figsize, **kwargs)
    : Create flattened axes.
  • make_grouped_bar(...)
    : Build grouped bars with publication defaults.
  • make_trend(...)
    : Build trend lines with optional confidence shadow.
  • make_heatmap(...)
    : Build heatmaps with optional labels and annotations.
  • make_scatter(...)
    : Build clean scatter plots.
  • make_sphere_illustration(...)
    : Build conceptual shaded sphere panels.
  • finalize_figure(fig, out_path, formats=None, dpi=300, pad=0.05)
    : Save outputs consistently.
  • FigureStyle(...)
    :配置字体样式和坐标轴线条宽度。
  • apply_publication_style(style=None)
    :应用全局rcParams设置。
  • create_subplots(nrows, ncols, figsize, **kwargs)
    :创建扁平化的坐标轴对象。
  • make_grouped_bar(...)
    :使用出版默认设置构建分组条形图。
  • make_trend(...)
    :构建带可选置信区间阴影的趋势线。
  • make_heatmap(...)
    :构建带可选标签和注释的热图。
  • make_scatter(...)
    :构建简洁的散点图。
  • make_sphere_illustration(...)
    :构建带阴影的球形概念示意图。
  • finalize_figure(fig, out_path, formats=None, dpi=300, pad=0.05)
    :统一保存输出文件。

Style Policy

风格规范

  • Use Helvetica/Arial-like sans-serif families.
  • Remove top/right spines.
  • Keep legends frameless.
  • Use semantic palette mapping:
    • blue for target/proposed method,
    • green for improvements,
    • red for contrasts/baselines,
    • neutral for support categories.
  • Use
    dpi=300
    by default and
    dpi=600
    for dense bar panels.
  • 使用类似Helvetica/Arial的无衬线字体。
  • 移除顶部和右侧的坐标轴边框。
  • 图例不使用边框。
  • 使用语义化配色方案:
    • 蓝色:目标/提出的方法,
    • 绿色:改进项,
    • 红色:对比/基线,
    • 中性色:支持类内容。
  • 默认使用
    dpi=300
    ,密集条形图面板使用
    dpi=600

Practical Defaults

实用默认设置

  • Dense benchmark bars:
    FigureStyle(font_size=24, axes_linewidth=3)
    and wide canvas.
  • Compact analysis charts:
    FigureStyle(font_size=15 or 16, axes_linewidth=2)
    .
  • Finalize every figure through
    finalize_figure(...)
    instead of direct
    plt.savefig(...)
    .
  • 密集基准条形图:使用
    FigureStyle(font_size=24, axes_linewidth=3)
    并搭配宽画布。
  • 紧凑分析图表:使用
    FigureStyle(font_size=15或16, axes_linewidth=2)
  • 所有图表均通过
    finalize_figure(...)
    完成导出,而非直接使用
    plt.savefig(...)

Dependencies

依赖项

  • Python 3.8+
  • matplotlib
  • numpy
  • Python 3.8及以上版本
  • matplotlib
  • numpy

References

参考资料

  • Read
    references/design_theory.md
    when you need style rationale and reproduction rules.
  • 如需了解风格设计依据和复现规则,请阅读
    references/design_theory.md