sci-figures 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. sci_figures-0.3.0/.claude-plugin/plugin.json +11 -0
  2. sci_figures-0.3.0/.github/workflows/lint.yaml +20 -0
  3. sci_figures-0.3.0/.github/workflows/release.yaml +72 -0
  4. sci_figures-0.3.0/.github/workflows/test.yaml +24 -0
  5. sci_figures-0.3.0/.gitignore +13 -0
  6. sci_figures-0.3.0/.pre-commit-config.yaml +26 -0
  7. sci_figures-0.3.0/LICENSE +21 -0
  8. sci_figures-0.3.0/PKG-INFO +92 -0
  9. sci_figures-0.3.0/README.md +59 -0
  10. sci_figures-0.3.0/pyproject.toml +62 -0
  11. sci_figures-0.3.0/skills/sci-figures/SKILL.md +86 -0
  12. sci_figures-0.3.0/skills/sci-figures/examples/fig1_moscot.py +328 -0
  13. sci_figures-0.3.0/skills/sci-figures/examples/fig1_moscot_legend.md +2 -0
  14. sci_figures-0.3.0/skills/sci-figures/examples/fig1_moscot_outline.md +27 -0
  15. sci_figures-0.3.0/skills/sci-figures/examples/fig2_spatial.py +633 -0
  16. sci_figures-0.3.0/skills/sci-figures/examples/fig2_spatial_data.py +229 -0
  17. sci_figures-0.3.0/skills/sci-figures/examples/fig2_spatial_legend.md +2 -0
  18. sci_figures-0.3.0/skills/sci-figures/examples/fig2_spatial_outline.md +58 -0
  19. sci_figures-0.3.0/skills/sci-figures/examples/resources/figure_conventions.yaml +31 -0
  20. sci_figures-0.3.0/skills/sci-figures/references/legends.md +51 -0
  21. sci_figures-0.3.0/skills/sci-figures/references/review.md +62 -0
  22. sci_figures-0.3.0/skills/sci-figures/references/setup.md +37 -0
  23. sci_figures-0.3.0/skills/sci-figures/references/style.md +82 -0
  24. sci_figures-0.3.0/src/scifig/__init__.py +27 -0
  25. sci_figures-0.3.0/src/scifig/elements.py +216 -0
  26. sci_figures-0.3.0/src/scifig/export.py +74 -0
  27. sci_figures-0.3.0/src/scifig/fonts.py +50 -0
  28. sci_figures-0.3.0/src/scifig/layout.py +59 -0
  29. sci_figures-0.3.0/src/scifig/style.py +179 -0
  30. sci_figures-0.3.0/tests/conftest.py +11 -0
  31. sci_figures-0.3.0/tests/test_badge.py +112 -0
  32. sci_figures-0.3.0/tests/test_export.py +69 -0
  33. sci_figures-0.3.0/tests/test_scale_bar.py +38 -0
  34. sci_figures-0.3.0/uv.lock +4657 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "sci-figures",
3
+ "version": "0.3.0",
4
+ "description": "Nature-style research figures and their legends: message and outline first, then layout, visual conventions, export to one PDF per figure with editable Arial text, legend writing and independent layout and legend reviews. Ships a skill and the scifig Python package.",
5
+ "author": {
6
+ "name": "quadbio"
7
+ },
8
+ "homepage": "https://github.com/quadbio/sci-figures",
9
+ "license": "MIT",
10
+ "keywords": ["figures", "matplotlib", "scanpy", "spatialdata", "nature", "figure-legends", "scverse"]
11
+ }
@@ -0,0 +1,20 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: lint-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ pre-commit:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ - uses: actions/setup-python@v6
18
+ with:
19
+ python-version: "3.12"
20
+ - uses: pre-commit/action@v3.0.1
@@ -0,0 +1,72 @@
1
+ name: Release
2
+
3
+ # A version in .claude-plugin/plugin.json without its tag v<version> is unreleased: publish it, then tag it.
4
+ on:
5
+ push:
6
+ branches: [main]
7
+
8
+ concurrency:
9
+ group: release
10
+ cancel-in-progress: false
11
+
12
+ # Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/
13
+ permissions: {}
14
+
15
+ jobs:
16
+ check:
17
+ runs-on: ubuntu-latest
18
+ permissions:
19
+ contents: read
20
+ outputs:
21
+ version: ${{ steps.version.outputs.version }}
22
+ tagged: ${{ steps.version.outputs.tagged }}
23
+ steps:
24
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
25
+ with:
26
+ persist-credentials: false
27
+ - id: version
28
+ run: |
29
+ version=$(jq -r .version .claude-plugin/plugin.json)
30
+ echo "version=$version" >> "$GITHUB_OUTPUT"
31
+ if git ls-remote --exit-code --tags origin "refs/tags/v$version" > /dev/null; then
32
+ echo "tagged=true" >> "$GITHUB_OUTPUT"
33
+ else
34
+ echo "tagged=false" >> "$GITHUB_OUTPUT"
35
+ fi
36
+
37
+ publish:
38
+ name: Upload release to PyPI
39
+ needs: check
40
+ if: needs.check.outputs.tagged == 'false'
41
+ runs-on: ubuntu-latest
42
+ environment:
43
+ name: pypi
44
+ url: https://pypi.org/p/sci-figures
45
+ permissions:
46
+ contents: read
47
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
48
+ steps:
49
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
50
+ with:
51
+ filter: blob:none
52
+ fetch-depth: 0
53
+ persist-credentials: false
54
+ - name: Install uv
55
+ uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
56
+ with:
57
+ enable-cache: false
58
+ - name: Build package
59
+ run: uv build
60
+ - name: Publish package distributions to PyPI
61
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3: twine 7 reads metadata 2.5
62
+
63
+ tag:
64
+ needs: [check, publish]
65
+ runs-on: ubuntu-latest
66
+ permissions:
67
+ contents: write
68
+ steps:
69
+ - run: gh release create "v$VERSION" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" --title "v$VERSION" --generate-notes
70
+ env:
71
+ GH_TOKEN: ${{ github.token }}
72
+ VERSION: ${{ needs.check.outputs.version }}
@@ -0,0 +1,24 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: test-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.12", "3.14"]
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+ - uses: astral-sh/setup-uv@v6
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - run: uv run --locked --group dev python -m scifig.fonts # the style refuses to run without Arial
24
+ - run: uv run --locked --group dev pytest
@@ -0,0 +1,13 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ .DS_Store
9
+ .claude/settings.local.json
10
+ .claude/worktrees/
11
+ figures/
12
+ .preview/
13
+ data/
@@ -0,0 +1,26 @@
1
+ exclude: ^uv\.lock$
2
+
3
+ repos:
4
+ - repo: https://github.com/astral-sh/ruff-pre-commit
5
+ rev: v0.15.19
6
+ hooks:
7
+ - id: ruff-check
8
+ args: [--fix, --exit-non-zero-on-fix]
9
+ - id: ruff-format
10
+
11
+ - repo: https://github.com/tox-dev/pyproject-fmt
12
+ rev: v2.25.0
13
+ hooks:
14
+ - id: pyproject-fmt
15
+
16
+ - repo: https://github.com/pre-commit/pre-commit-hooks
17
+ rev: v6.0.0
18
+ hooks:
19
+ - id: check-json
20
+ - id: check-yaml
21
+ - id: end-of-file-fixer
22
+ - id: mixed-line-ending
23
+ args: [--fix=lf]
24
+ - id: trailing-whitespace
25
+ - id: check-merge-conflict
26
+ - id: detect-private-key
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 quadbio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.5
2
+ Name: sci-figures
3
+ Version: 0.3.0
4
+ Summary: Style, mm layout, recurring elements and export for Nature-style research figures with editable text.
5
+ Project-URL: Source, https://github.com/quadbio/sci-figures
6
+ Author: quadbio
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Requires-Python: >=3.12
14
+ Requires-Dist: matplotlib>=3.8
15
+ Provides-Extra: examples
16
+ Requires-Dist: anndata; extra == 'examples'
17
+ Requires-Dist: pyyaml; extra == 'examples'
18
+ Requires-Dist: scanpy>=1.10; extra == 'examples'
19
+ Provides-Extra: spatial-examples
20
+ Requires-Dist: anndata; extra == 'spatial-examples'
21
+ Requires-Dist: cellcharter>=0.3.7; extra == 'spatial-examples'
22
+ Requires-Dist: geopandas; extra == 'spatial-examples'
23
+ Requires-Dist: lightning; extra == 'spatial-examples'
24
+ Requires-Dist: pyyaml; extra == 'spatial-examples'
25
+ Requires-Dist: scanpy>=1.10; extra == 'spatial-examples'
26
+ Requires-Dist: shapely>=2; extra == 'spatial-examples'
27
+ Requires-Dist: sopa>=2.2; extra == 'spatial-examples'
28
+ Requires-Dist: spatialdata-plot>=0.4.2; extra == 'spatial-examples'
29
+ Requires-Dist: spatialdata>=0.8; extra == 'spatial-examples'
30
+ Requires-Dist: squidpy>=1.8; extra == 'spatial-examples'
31
+ Requires-Dist: torch; extra == 'spatial-examples'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # sci-figures
35
+
36
+ A Claude Code plugin for Nature-style research figures (main, Extended Data, supplementary) and their legends. The
37
+ agent writes the plotting code (matplotlib, seaborn, scanpy, spatialdata-plot); the skill says what the result must
38
+ achieve, from the figure's message to its export as one PDF with editable Arial text, and has independent reviewers
39
+ check the layout and the legend against the code.
40
+
41
+ | Part | What it does |
42
+ | --- | --- |
43
+ | `skills/sci-figures/` | The workflow, visual and legend conventions, the two reviews, setup, and two complete example figures (outline, script, legend). Loaded on demand. |
44
+ | `src/scifig/` | `apply_style`, mm layout (`new_figure`, `add_axes_mm`, `panel_letter`), recurring elements (`badge`, `colorbar`, `embedding_axes`, `scale_bar`) and `save`, which checks fonts, sizes and raster resolution. |
45
+
46
+ ## Use
47
+
48
+ Ask Claude for a figure, a panel or a legend in the repo that holds the figure scripts.
49
+
50
+ 1. It agrees the format and an outline with you (message, story line, one entry per panel) and saves the outline
51
+ next to the script.
52
+ 2. It computes the plotted data, then writes one script per figure that only loads and plots it.
53
+ 3. It checks the preview against the layout checklist, writes the legend from the code and the data, and runs the
54
+ layout and legend reviews in parallel.
55
+ 4. It shows you the PDF with its legend and lists the review findings it declined.
56
+
57
+ Colors and marks shared across a paper's figures live in the repo's `resources/figure_conventions.yaml`.
58
+
59
+ ## Install
60
+
61
+ **The plugin**, once per machine, from the [quadbio marketplace](https://github.com/quadbio/claude-plugins).
62
+
63
+ **The package**, Arial and TeX (for equations): [`skills/sci-figures/references/setup.md`](skills/sci-figures/references/setup.md).
64
+
65
+ ## Develop
66
+
67
+ ```bash
68
+ uv sync --group dev
69
+ uv run python -m scifig.fonts # Arial, once per machine
70
+ uv run pytest # the equation test is skipped without TeX
71
+ uv run pre-commit run --all-files
72
+ claude plugin validate .
73
+ claude --plugin-dir . # try the skill from this checkout
74
+ ```
75
+
76
+ The example figures: `uv run --extra examples python skills/sci-figures/examples/fig1_moscot.py` writes
77
+ `figures/fig1_moscot.pdf`, its legend and preview (needs TeX). The spatial one needs the `spatial-examples` extra and the
78
+ Xenium dataset (`fig2_spatial_outline.md`, Source): run `fig2_spatial_data.py` (about 7 min on 8 cores), then
79
+ `fig2_spatial.py`.
80
+
81
+ For live package edits in a figure repo, depend on the checkout instead:
82
+ `sci-figures = { path = "../sci-figures", editable = true }`.
83
+
84
+ ## Release
85
+
86
+ Bump `version` in `.claude-plugin/plugin.json` and merge: the marketplace follows `main`, and users update when the
87
+ version changes. On that merge, `release.yaml` publishes the package to PyPI as `sci-figures`, then tags `v<version>` and
88
+ creates a GitHub Release.
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,59 @@
1
+ # sci-figures
2
+
3
+ A Claude Code plugin for Nature-style research figures (main, Extended Data, supplementary) and their legends. The
4
+ agent writes the plotting code (matplotlib, seaborn, scanpy, spatialdata-plot); the skill says what the result must
5
+ achieve, from the figure's message to its export as one PDF with editable Arial text, and has independent reviewers
6
+ check the layout and the legend against the code.
7
+
8
+ | Part | What it does |
9
+ | --- | --- |
10
+ | `skills/sci-figures/` | The workflow, visual and legend conventions, the two reviews, setup, and two complete example figures (outline, script, legend). Loaded on demand. |
11
+ | `src/scifig/` | `apply_style`, mm layout (`new_figure`, `add_axes_mm`, `panel_letter`), recurring elements (`badge`, `colorbar`, `embedding_axes`, `scale_bar`) and `save`, which checks fonts, sizes and raster resolution. |
12
+
13
+ ## Use
14
+
15
+ Ask Claude for a figure, a panel or a legend in the repo that holds the figure scripts.
16
+
17
+ 1. It agrees the format and an outline with you (message, story line, one entry per panel) and saves the outline
18
+ next to the script.
19
+ 2. It computes the plotted data, then writes one script per figure that only loads and plots it.
20
+ 3. It checks the preview against the layout checklist, writes the legend from the code and the data, and runs the
21
+ layout and legend reviews in parallel.
22
+ 4. It shows you the PDF with its legend and lists the review findings it declined.
23
+
24
+ Colors and marks shared across a paper's figures live in the repo's `resources/figure_conventions.yaml`.
25
+
26
+ ## Install
27
+
28
+ **The plugin**, once per machine, from the [quadbio marketplace](https://github.com/quadbio/claude-plugins).
29
+
30
+ **The package**, Arial and TeX (for equations): [`skills/sci-figures/references/setup.md`](skills/sci-figures/references/setup.md).
31
+
32
+ ## Develop
33
+
34
+ ```bash
35
+ uv sync --group dev
36
+ uv run python -m scifig.fonts # Arial, once per machine
37
+ uv run pytest # the equation test is skipped without TeX
38
+ uv run pre-commit run --all-files
39
+ claude plugin validate .
40
+ claude --plugin-dir . # try the skill from this checkout
41
+ ```
42
+
43
+ The example figures: `uv run --extra examples python skills/sci-figures/examples/fig1_moscot.py` writes
44
+ `figures/fig1_moscot.pdf`, its legend and preview (needs TeX). The spatial one needs the `spatial-examples` extra and the
45
+ Xenium dataset (`fig2_spatial_outline.md`, Source): run `fig2_spatial_data.py` (about 7 min on 8 cores), then
46
+ `fig2_spatial.py`.
47
+
48
+ For live package edits in a figure repo, depend on the checkout instead:
49
+ `sci-figures = { path = "../sci-figures", editable = true }`.
50
+
51
+ ## Release
52
+
53
+ Bump `version` in `.claude-plugin/plugin.json` and merge: the marketplace follows `main`, and users update when the
54
+ version changes. On that merge, `release.yaml` publishes the package to PyPI as `sci-figures`, then tags `v<version>` and
55
+ creates a GitHub Release.
56
+
57
+ ## License
58
+
59
+ MIT
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ build-backend = "hatchling.build"
3
+ requires = [ "hatchling" ]
4
+
5
+ [project]
6
+ name = "sci-figures"
7
+ description = "Style, mm layout, recurring elements and export for Nature-style research figures with editable text."
8
+ readme = "README.md"
9
+ license = "MIT"
10
+ authors = [ { name = "quadbio" } ]
11
+ requires-python = ">=3.12"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3 :: Only",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ ]
18
+ dynamic = [ "version" ]
19
+ dependencies = [ "matplotlib>=3.8" ]
20
+ optional-dependencies.examples = [ "anndata", "pyyaml", "scanpy>=1.10" ]
21
+ optional-dependencies.spatial-examples = [
22
+ "cellcharter>=0.3.7",
23
+ "geopandas",
24
+ "lightning",
25
+ "sci-figures[examples]",
26
+ "shapely>=2",
27
+ "sopa>=2.2",
28
+ "spatialdata>=0.8",
29
+ "spatialdata-plot>=0.4.2",
30
+ "squidpy>=1.8",
31
+ "torch",
32
+ ]
33
+ urls.Source = "https://github.com/quadbio/sci-figures"
34
+
35
+ [dependency-groups]
36
+ dev = [ "pre-commit", "pytest" ]
37
+
38
+ [tool.hatch]
39
+ version.path = ".claude-plugin/plugin.json"
40
+ version.pattern = '"version": "(?P<version>[^"]+)"'
41
+ build.targets.wheel.packages = [ "src/scifig" ]
42
+
43
+ [tool.ruff]
44
+ line-length = 120
45
+ src = [ "skills/sci-figures/examples", "src", "tests" ]
46
+ lint.select = [ "B", "C4", "D", "E", "F", "I", "UP" ]
47
+ lint.ignore = [
48
+ "D100",
49
+ "D104",
50
+ "D105",
51
+ "D107",
52
+ "D203",
53
+ "D213",
54
+ "D401", # docstrings may open with a noun phrase
55
+ ]
56
+ lint.per-file-ignores."skills/*" = [ "D" ]
57
+ lint.per-file-ignores."tests/*" = [ "D" ]
58
+ lint.pydocstyle.convention = "numpy"
59
+
60
+ [tool.pytest]
61
+ ini_options.testpaths = [ "tests" ]
62
+ ini_options.addopts = [ "--import-mode=importlib" ]
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: sci-figures
3
+ description: >-
4
+ Guidelines for Nature-style research figures (main, Extended Data, supplementary) and their legends: planning the
5
+ message and outline, layout, visual conventions, colors, scale bars, export to one PDF per figure with editable Arial
6
+ text, legend writing, and independent layout and legend reviews. Use whenever creating, restyling or assembling a
7
+ paper figure or panel; or writing or revising a figure legend.
8
+ ---
9
+
10
+ # Scientific figures and legends
11
+
12
+ You write the plotting code (matplotlib, seaborn, scanpy); this skill says what the result must achieve. The `scifig` package supplies only the style, a few recurring elements and the export.
13
+
14
+ Paths starting with `references/` or `examples/` are in this skill's folder; all others (`figures/`, `resources/`, scripts) are in the repository you are working in.
15
+
16
+ ## Principles
17
+ - **One message.** A figure makes one point along one story line. The message is the legend's title; every panel advances the story.
18
+ - **Visual, not verbal.** The figure conveys its message through visual elements. Minimize text; prefer position, color, marks and direct labels to words.
19
+ - **Words before pictures.** Format and outline are agreed with the user before anything is drawn.
20
+ - **Reproducible.** One script per figure; it only loads and plots data computed beforehand.
21
+ - **A restyle changes the look, not the content.** Keep a method's native encodings (PAGA node size = cell count)
22
+ and make style rules coexist with them.
23
+ - **Ask when in doubt** about content, conventions or layout.
24
+ - **Precedence:** the user's instructions, then this skill, then Nature's [research figure guide](https://research-figure-guide.nature.com/) and [formatting guide](https://www.nature.com/nature/for-authors/formatting-guide), consulted for anything not covered here.
25
+
26
+ | File | Covers |
27
+ |---|---|
28
+ | `references/style.md` | visual conventions and panel layout |
29
+ | `references/legends.md` | legend conventions |
30
+ | `references/review.md` | the layout and legend reviews |
31
+ | `examples/` | two complete figures: outline, script, legend |
32
+ | `references/setup.md` | installing scifig, Arial and TeX |
33
+
34
+ ## Workflow
35
+
36
+ ### 1. Plan
37
+ Agree the format: main, Extended Data or supplementary; width and approximate height (`references/style.md`, Page). Then iterate on an outline until the user approves it, and save it next to the figure script. When the user points at an earlier figure to build on, first list every block it has, from its code or PDF:
38
+ ```markdown
39
+ **Message:** <one sentence; becomes the legend title>
40
+ **Story line:** <how the panels build the message, in order>
41
+
42
+ **a** <panel name>
43
+ - Role: <what it adds to the story line>
44
+ - Shows: <data, subset, n>
45
+ - Plot: <plot type; x, y; color, size and other encodings>
46
+ - Shared: <axes, keys or marks shared with other panels, or "none">
47
+ - Source: <script or file producing the plotted data; "to be computed" if not yet>
48
+ ```
49
+ Cut panels that don't advance the message. Resolve open questions (n, tests, subsets), then compute and save all plotted data.
50
+
51
+ ### 2. Build
52
+ Find the repo's colors (`references/style.md`, Color and marks) and the conventions of existing figure scripts; see `examples/fig1_moscot.py` (plots and a schematic) and `examples/fig2_spatial.py` (images and spatial data). The recurring elements:
53
+ ```python
54
+ import scanpy as sc # if used
55
+ import scifig as sf
56
+ sf.apply_style() # after importing scanpy; never sc.set_figure_params
57
+ fig = sf.new_figure(183, 120) # mm
58
+ ax = sf.add_axes_mm(fig, left, top, w, h) # mm from the top-left corner
59
+ sf.embedding_axes(ax) # UMAP1/UMAP2 arrows instead of a frame
60
+ sf.colorbar(mappable, cax, label="Expression") # labelled at its ends
61
+ sf.scale_bar(ax, 100, "µm", data_unit_size=px_um)
62
+ sf.badge(ax, x, y, color, id="3") # an entity's mark
63
+ ax.legend(handles=[sf.badge_handle(color, id="3", label="Forebrain")]) # the same mark as a key entry
64
+ sf.panel_letter(fig, "a", left, top, title="...", over=ax) # title centered over ax
65
+ sf.save(fig, "figures/fig2_atlas", legend="figures/fig2_atlas_legend.md")
66
+ ```
67
+ If `scifig`, Arial or LaTeX (for equations) is missing, follow `references/setup.md` or tell the user.
68
+
69
+ ### 3. Check
70
+ Go through the layout review's checklist (`references/review.md`) yourself, on the preview and zoomed crops of its dense regions. Fix and repeat.
71
+
72
+ ### 4. Legend
73
+ Write the legend following `references/legends.md`, from the plotting code, the data (compute n, never estimate it) and the discussion that led to the figure.
74
+
75
+ ### 5. Review
76
+ On a near-final draft, run both reviews in `references/review.md` in parallel; afterwards only when the user asks.
77
+
78
+ ### 6. Present
79
+ Whenever you show the user a figure (drafts included), show the PDF, not the preview, with its current legend in the same message. At the end, send the PDF and the legend file with the size and raster resolution `sf.save` prints, and list the review findings you declined, each with its reason.
80
+
81
+ ## Output
82
+ - `figures/<name>.pdf`, named `fig<N>_<topic>` with figures numbered in reading order (`fig1_overview` ... `figN_<topic>`), so a discussion can name one: vector, with text as editable Arial, except dense scatters and images, which you rasterize (`rasterized=True`). `sf.save` writes rasters at 1200 dpi, lowered to no less than 300 dpi to keep the PDF within 5 MB.
83
+ - `figures/<name>_legend.md`: the legend, next to the PDF (`sf.save(..., legend=)` copies it there if it is kept elsewhere, e.g. next to the script).
84
+ - `figures/.preview/<name>.png`: for you and the reviewers only; never show or send it to the user.
85
+
86
+ In Illustrator, each axes sits in a clipping mask (Object > Clipping Mask > Release). Changes made there are not reproduced by the script; limit them to what the script cannot do (e.g. illustrations) and tell the user which parts they are.