SuperAPI AI Directory

light-figure-drawing

Coding & development

View repository

Updated 10-16 06:23

About this skill

Professional Plotting and Figure Composition

Tool Selection (by figure type, with core calls)

  • Statistical plots/reproducible figures (first choice):
    • matplotlib: most controllable. Figure composition plt.subplots(figsize=(7,5), constrained_layout=True), for irregular layouts use GridSpec(spanning cells gs[0,:])。
    • seaborn: statistical/distribution/categorical plots.sns.set_theme(style="ticks", context="paper", palette="colorblind") + sns.despine(); for faceted tiling use figure-level (relplot/catplot 's col=/row=), for manual tiling use axes-level (scatterplot(ax=...))。
    • plotly: interactive/3D, for static submission fig.write_image("f.pdf", scale=3)(requires kaleido),template="simple_white"。
    • altair: declarative, strongly reproducible.chart.save("f.svg", scale_factor=3)(requires vl-convert-python), for composition use c1 | c2 / c1 & c2。
    • ggplot2(R):+ theme_classic() + scale_color_viridis_d(), for composition use patchwork(p1+p2 and plot_annotation(tag_levels="a") auto-numbering).
  • Framework diagrams/flowcharts/structural diagrams:
    • Graphviz(automatic layout):digraph{rankdir=LR; node[shape=box,style=rounded]; A->B}, choose the right engine dot(hierarchical)/neato(undirected)/fdp(large graphs),rank=same align on the same layer.
    • TikZ/PGFPlots(fonts unified with the main text):\begin{axis}...\addplot table{data.dat};, in the preamble \pgfplotsset{compat=1.18} unify the style, for large figures use the external library cache.
    • Mermaid(documentation/draft):graph TD; A[框]-->|标签|B{判断},mmdc -i in.mmd -o out.svg export.
    • Draw.io(for system/architecture diagrams that need an editable vector source + version control):.drawio is mxGraph XML, can be generated programmatically; there is the official jgraph/drawio-mcp (diagram-as-code, AI can generate/modify diagrams), CLI drawio --export --format pdf/svg renders the figure. More controllable than Graphviz automatic layout, more expressive than Mermaid (aligned with the first choice listed in m09 figure-planning; for configuration see the recommended MCP table in the README).
    • Fine retouching and layout: Illustrator / Inkscape.
  • Fine scientific figures/journal curves:
    • Origin: Export Graphs precisely sets Width/Height+DPI according to the publisher (TIFF 600dpi), can Export as AI convert to Illustrator; .otp templates lock in the style.
    • MATLAB:exportgraphics(ax,"f.pdf","ContentType","vector") outputs vector,"Resolution",600 outputs bitmap; for composition use tiledlayout + nexttile(TileSpacing="compact")。
  • Schematic/mechanism diagrams/graphical abstract: for life science icon libraries you can use BioRender made by hand (note export licensing and resolution; its official MCP only queries and cannot draw, so use it only manually, not as a programmatic path).
  • 3D structure/molecule/scientific visualization:Blender(open source, programmatic modeling and renderingnot AI image generation; the mature route uses plugins such as Molecular Nodes/SciBlend, there are community/official MCPs but driving scientific visualization with them is still exploratory); 3D renders used as paper figures must have real, reproducible data and the rendering parameters must be stated, see the "Blender" section in m09 figure-planning references.
  • Composition/layout: matplotlib subplots/GridSpec, Illustrator (layer + artboard alignment), python-pptx (add_picture(..., width=Inches(3)), layout[6] blank page). Prefer reproducible (code) solutions, making it easy to change data and re-output; for final retouching/composing large figures then go into Illustrator/Inkscape. Specific decisions same as a09.

One-line journal style and export script (assets bundled with this skill)

  • Style:plt.style.use("assets/publication.mplstyle") is the general base; overlay per journal plt.style.use(["assets/publication.mplstyle","assets/nature.mplstyle"])(or science.mplstyle). All three use the Okabe-Ito colorblind-safe color cycle + sans-serif + editable vector text (pdf/ps fonttype42, svg not converted to outlines).
  • Export:scripts/figure_export.py
    • save_publication_figure(fig, basename, formats=("pdf","png","svg"), dpi=600) multiple formats + DPI, automatically create directories, force text to remain editable.
    • save_for_journal(fig, basename, journal, column) set physical dimensions per journal specs (mm→in) then export, returns (paths, info)。
    • check_figure_size(fig, journal=, column=) validate column width (mm) and minimum font size (pt),measured=True,path= and can also read back the saved file to measure the actual width and recheck bbox tight silent cropping.
    • check_scaled_fonts(fig, journal=, column=) validate theeffective font size——after "drawing on a large canvas then scaling down to column width"; if save_for_journal has already been used to set the exact column width (scale≈1), it will necessarily report "no risk"; this is an expected no-op, not a bug, and the standard workflow does not need to run it again.
    • check_export_compliance(path, journal, column=) consume the previously idle spec fields: measured dpi≥min_dpi, file size≤max_file_mb, height≤max_height_px, format∈preferred_formats (bitmaps read with Pillow; vector/no Pillow skipped without guessing).
    • save_for_journal check for font fallback before export: the rcParams first choice Arial/Helvetica is unavailable on Linux/CI and will silently fall back to DejaVu; on fallback, emit a WARNING and include it in info["font"], making "font consistent with body text" verifiable.
    • JOURNAL_SPECS built-in per-journal spec dictionary (including verified markers).
  • Color scheme:scripts/color_palettes.py
    • OKABE_ITO / OKABE_ITO_LIST 8-color constants;sequential_cmap() / diverging_cmap() / discrete_cmap();apply_palette() set the current color cycle.
    • to_grayscale()、simulate_cvd(kind=deuteranomaly/protanomaly/tritanomaly)、preview_palette() output original color/grayscale/three colorblind comparison figures. If colorspacious is available, use the exact algorithm; if missing, automatically degrade to a linear approximation (cvd_backend() can be checked).
  • Honesty lint:scripts/figure_integrity_lint.py — statically scan plotting code and flag common misleading practices: secretly truncated y-axis (including set_ylim(bottom=) keyword form), dual y-axis spurious correlation, bar/sns.barplot without error bars, error bars without specifying type (.std() data computation is no longer mistaken for a type declaration), jet/rainbow colormaps, 3D distortion.python scripts/figure_integrity_lint.py --file plot.py(including --selftest)。counterexample teaching material examples/bad_figure_example.py(intentionally violating, can hit multiple items end-to-end). Specs see references/figure_integrity.md. Only warns, does not block; final judgment is left to the author.Limitation: only covers matplotlib/seaborn static regex; honesty of plotly/altair/ggplot2/MATLAB pipelines is not checked, and those require manual comparison against figure_integrity.md.
  • Examples(all can be run through with python examples/xxx.py , saving figures with Agg):
    • example_matplotlib_multipanel.py: GridSpec irregular layout + (a)(b)(c) labels + error bars + significance stars.
    • example_seaborn_stats.py: box/violin/bar statistical comparison + despine.
    • example_framework.dot + example_framework_render.py: Graphviz framework diagram; if the dot binary is available, render it; otherwise degrade to a matplotlib block diagram.

Per-journal hard spec table (column width mm + DPI + format + minimum font size)

The single source of truth for column width numbers = scripts/figure_export.py in JOURNAL_SPECS; the table below is a human-readable mirror of it. If it disagrees with the script, the script prevails (to change numbers, change only the script). verified=measured: the journal's figure spec page has been curled and the HTTP code recorded; the rest are compiled from public guidelines but were not individually measured this time (mostly due to paywalls/anti-scraping 403). Before submission, please refer to the target journal's "latest" author guidelines.

Journal Single-column width Double-column/full-page width Minimum font size Line DPI Halftone/photo DPI Preferred format Measured
Nature 89 mm 183 mm 5 pt (panel labeled 8pt bold a,b,c; body text ≤7pt) 600 300–600 PDF/TIFF/EPS (do not convert text to outlines, Helvetica/Arial) ✅ HTTP200
PLOS 83 mm 140 mm(1.5 column) / 190 mm 8 pt(8–12pt,Arial/Times/Symbol) 600 300–600 TIFF/EPS only;789–2250px@300dpi,<10MB ✅ HTTP200
Science (AAAS) 55 mm (5.5cm) 120 mm(12cm) / full page 183 mm(18.3cm) 5 pt (usually 6–9pt) 600 300 EPS/PDF/AI/TIFF, sans-serif ✅ Three-tier system verified via multiple online sources (2026-06-11)
Cell Press 85 mm 174 mm 5 pt 1000 (line art) 300 PDF/AI/EPS/TIFF ⚠️ Page 403 not measured
IEEE 88.9 mm(3.5in) 181 mm(7.16in) 8 pt 600 300 PDF/EPS/TIFF ⚠️ Not measured item by item
Elsevier 90 mm 140 mm(1.5 column) / 190 mm 7 pt 1000 (line art) 300 (color/grayscale), combination 500 PDF/EPS/TIFF ⚠️ Page 404 not measured
MDPI 170 mm (single-column body width; figures at this width or integer fractions thereof) 170 mm 8 pt 1000 (line/combination) 300 (photos) TIFF/PNG/EPS ⚠️ Paywall not measured; includes db01's Animals/Agronomy/Sensors/Remote Sensing

custom escape hatch: for journals not yet in the table above (e.g. Chinese journals) use save_for_journal(fig, base, journal="custom", custom_width_mm=86.0) to directly pass the physical column width (mm); validation is the same check_figure_size(fig, journal="custom", custom_width_mm=86.0)。Column-width data must have a source (db01 card or measurement record); no guessing allowed. Measured column widths for Chinese journals are recorded in db01 risk_note (2026-06-11, measured with pdfplumber): Transactions of the Chinese Society of Agricultural Engineering single column 86 / full page 180; Scientia Agricultura Sinica, Acta Agronomica Sinica single column 81 / full page 170; Transactions of the Chinese Society for Agricultural Machinery pending verification (PDF entry blocked by anti-scraping).

Values and JOURNAL_SPECS share the same source and can be read directly in code (e.g. figure_export.JOURNAL_SPECS["nature"])。

Aesthetics and standards (submission-grade)

  • Color scheme: colorblind-friendly—for matplotlib/seaborn use viridis/cividis/colorblind, for R use scale_*_viridis, avoid jet/rainbow for continuous data. Use a unified palette within the same paper (register in db07);If the project has databases/db09-projects/projects/<project_name>/palette.json then its colors must be used(a visual SSOT instance shared with PPT/frontend; take primary/accent/semantic colors as-is, do not create another set; see db09 README for schema), otherwise use the palette recommended by the db07 card. Do not exceed the necessary number of colors (discrete ≤8 categories; specify manually if exceeded).
  • Font: consistent with the body text (usually Times/Arial); font size still readable after scaling (≥6–8pt). For seaborn use context="paper" to set font size globally; set physical dimensions according to the target column width (single column ≈3.5in, double column ≈7.2in) to avoid scaling distortion after submission.
  • Lines/markers: clearly distinguished, still distinguishable in black-and-white printing (distinguish by both linestyle and marker, not by color alone); use absolute values (pt) for line width.
  • Resolution/format: vector preferred (PDF/SVG/EPS); bitmap line art ≥600dpi, with photos ≥300dpi.Keep text editablefor easy secondary refinement: for matplotlib set rcParams["pdf.fonttype"]=42; for R use device=cairo_pdf; for MATLAB use exportgraphics ContentType=vector. EPS does not support transparency; for a transparent background use PDF/SVG.
  • Elements: axis labels + units, legend, error bars, significance markers, remove chart junk (excess gridlines/borders,sns.despine() or theme_classic())。
  • caption: self-contained, understandable on its own.

Figure group logic

  • Align similar items, share axes/color scales, unify sizes. For matplotlib use constrained_layout Automatically align shared color scales; for ggplot use facet_* or patchwork; for MATLAB use tiledlayout。
  • Subfigure numbering (a)(b)(c), concise titles. patchwork tag_levels="a" can auto-number.
  • Use whitespace and grouping to convey hierarchy and highlight the main result.
  • Assemble the final large figure: export each subfigure as vector (SVG/PDF) → place into Illustrator/Inkscape → layer management + Align + unify fonts and line widths → add numbering → export per journal requirements (PDF/EPS/TIFF, print often CMYK). For command-line assembly/format conversion, use Inkscape 1.x --export-type / --actions。

Pre-submission self-check list

  • Physical size = target column width? Font size ≥6–8pt after scaling?
  • Are colors colorblind-safe? Distinguishable in black-and-white printing (line styles + markers)?
  • Vector output with editable text (fonttype42 / svg.fonttype=none / cairo_pdf / vector)? Bitmap dpi up to standard?
  • Axes have labels + units? Legend/error bars/significance markers complete? Remove chart junk?
  • Honesty (do not mislead; reviewers will check): see references/figure_integrity.md, can run scripts/figure_integrity_lint.py to scan plotting code. Key points: error bars must state in the caption whether they are SD/SEM/95%CI and specify n=; y-axis truncation must explicitly mark the break (do not secretly truncate to exaggerate differences); use dual y-axes with caution (prone to creating spurious correlations; split them apart if possible); for small samples, prefer scatter/box plots to show the raw distribution, do not use bars to hide the distribution; do not artificially tighten/enlarge axis ranges to exaggerate effects.
  • AI-generated images (2026 submission red line): Was this figure generated or altered using generative AI (DALL·E/Midjourney/SD/GPT Image, etc.)? Absolutely prohibited for data figures—Nature/Science/Elsevier, the three leading publishers, all prohibit AI-generated paper images; the only exception is "AI itself is the research object/method" (must be disclosed reproducibly in methods). Paper figures should be drawn data-driven using your own mplstyle; m16's R6 image-generation pipeline only serves PPT/frontend and is strictly forbidden in the paper figure chain. For policy details and differences in each publisher's stance, see references/figure_integrity.mdthe "AI-generated image policy" section.
  • Consistent palette/font/line width across the whole paper (compare with db07)?

Working method

Implement figure by figure according to m09's planning card (light-figure-planning/templates/figure_plan_card.md, dual-layer fields: narrative layer + specification layer): provide runnable code or source files + preview description + design rationale. Read the upper narrative layer of the card to confirm the claim this figure is bound to and its role in the figure group; read the lower specification layer's source_card/target_journal/column and execute according to the card. When data is needed, go back to m06/m02 to get it. Polish repeatedly until it reaches top-conference visual quality.

  • Read source_card first (required): the planning card must carry source_card, pointing to databases/db07-figures/resources_real.md::figure_type or databases/db07-figures/figure_advanced_cards.md::figure_type。figure_cards.md is only a template index and cannot serve as an entity execution source; only source_card: new_canonical_candidate -> databases/db07-figures/resources_real.md(or databases/db07-figures/figure_advanced_cards.md) indicates that a new reusable pattern must be added and written back to db07.
  • Layered input fields: db07 base fields control the chart pattern (figure_type/purpose/data_required/layout/...); project execution fields control delivery (figure_id/target_journal/column/caption_draft/output_formats). Do not write a single project's F1/F2, caption, or export path back into a db07 entity card.
  • Do not guess column width: directly read the planning card's target_journal and column fields and pass them as-is to save_for_journal(fig, basename, journal=target_journal, column=column)—physical column width in mm, figsize, and minimum font size are all locked by JOURNAL_SPECS . If the planning card lacks these two fields, go back to the planning skill (light-figure-planning) to fill them in; do not guess the column width yourself (a wrong guess invalidates the entire figure's physical dimensions).column The value must be an existing key of that journal (single/double/full/onehalf)。JOURNAL_SPECS currently contains nature/science/cell/plos/ieee/elsevier/mdpi seven keys; out-of-table journals (such as Chinese journals) go through the journal="custom"+custom_width_mm=<mm> escape channel,column-width data must have a source (db01 card or measured record); guessing is prohibited。
  • Mandatory check after export: after exporting each figure, run check_figure_size(fig, journal=target_journal, column=column, measured=True, path=<落盘文件>) to re-verify the measured physical width, and run check_export_compliance(path, journal, column) to check dpi/size/format/height compliance;save_for_journal already automatically checks for missing fonts (see info["font"]).check_scaled_fonts Only needed in the "manually draw on a large canvas then scale down" workflow—when using save_for_journal to set an exact column width it will always report no risk, so it can be skipped. If the code figure involves error bars, truncated axes, dual y-axes, jet/rainbow, etc., then use scripts/figure_integrity_lint.py --file <plot.py> for an honesty check.

Outputs

Figure files (vector + raster) + generation code/source files + project style description (written to the repository root directory's databases/db09-projects/projects/<project_name>/version_history.md, for a07 to unify) + figure manifest(placed in the repository root directory's projects/<project_name>/figures/manifest.md). Only when a new cross-project reusable chart pattern has been added should the db07 canonical file be written back.

  • figure manifest: the single artifact delivered to m07, binding "figure file ↔ figure number ↔ caption". One entry per figure, containing:figure_id(reusing the F#/T# numbering from the m09 planning card, aligned with the m07 template [图位 F1]/[表位 T1] placeholders) + source_card + image file paths (vector + raster) + final caption + placement section + target_journal/column + export/font-size check results. Based on this, m07 replaces the placeholders with the actual figures and figure numbers, with no need to look back at the planning card. Example:
    - figure_id: F1
      source_card: databases/db07-figures/resources_real.md::模型框架图(architecture)
      files:
        vector: figs/framework.pdf
        bitmap: figs/framework.png
      caption: "图1. 方法整体框架:左输入经解耦表征模块……"
      section: 方法-框架
      target_journal: nature
      column: single
      checks:
        figure_size: pass
        scaled_fonts: pass
    

Interfaces

Driven by m09; handed to m12 for layout insertion; style consistency is maintained across figures by a07. Patent drawings: when commissioned to draw by m15 (light-ip-application), execute according to the references "Patent Drawing Specification" section—black-and-white vector lines, figure number arrangement, reference-sign lines not crossing, flowchart/block-diagram terminology consistent with the claims, and do not apply paper data-figure color schemes.


Item-by-item notes on each tool's real API/parameters/export commands/known pitfalls are in references.md.