psyclaw 0.28.0 → 0.28.2

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 (167) hide show
  1. package/README.md +5 -5
  2. package/agents/recommended/catalog.json +99 -0
  3. package/dist/apps/panel/index.html +5 -5
  4. package/dist/src/adapters/pi/extension.js +164 -18
  5. package/dist/src/adapters/pi/extension.js.map +1 -1
  6. package/dist/src/adapters/pi/rpc.d.ts +2 -0
  7. package/dist/src/adapters/pi/rpc.js +9 -2
  8. package/dist/src/adapters/pi/rpc.js.map +1 -1
  9. package/dist/src/agents/recommended-personas.d.ts +42 -0
  10. package/dist/src/agents/recommended-personas.js +135 -0
  11. package/dist/src/agents/recommended-personas.js.map +1 -0
  12. package/dist/src/ars/mode-editor.d.ts +20 -0
  13. package/dist/src/ars/mode-editor.js +57 -0
  14. package/dist/src/ars/mode-editor.js.map +1 -0
  15. package/dist/src/ars/profile.d.ts +4 -1
  16. package/dist/src/ars/profile.js +23 -6
  17. package/dist/src/ars/profile.js.map +1 -1
  18. package/dist/src/cli.js +6 -3
  19. package/dist/src/cli.js.map +1 -1
  20. package/dist/src/creation/contracts.d.ts +3 -0
  21. package/dist/src/creation/service.js +17 -5
  22. package/dist/src/creation/service.js.map +1 -1
  23. package/dist/src/index.d.ts +1 -0
  24. package/dist/src/index.js +1 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/orchestration/bundled-personas.d.ts +16 -0
  27. package/dist/src/orchestration/bundled-personas.js +101 -0
  28. package/dist/src/orchestration/bundled-personas.js.map +1 -0
  29. package/dist/src/orchestration/effects.d.ts +8 -0
  30. package/dist/src/orchestration/effects.js +39 -0
  31. package/dist/src/orchestration/effects.js.map +1 -0
  32. package/dist/src/orchestration/personas.d.ts +2 -1
  33. package/dist/src/orchestration/personas.js +20 -7
  34. package/dist/src/orchestration/personas.js.map +1 -1
  35. package/dist/src/orchestration/pi-executor.d.ts +9 -5
  36. package/dist/src/orchestration/pi-executor.js +55 -22
  37. package/dist/src/orchestration/pi-executor.js.map +1 -1
  38. package/dist/src/orchestration/research-agents.d.ts +3 -7
  39. package/dist/src/orchestration/research-agents.js +5 -69
  40. package/dist/src/orchestration/research-agents.js.map +1 -1
  41. package/dist/src/panel/server.js +6 -0
  42. package/dist/src/panel/server.js.map +1 -1
  43. package/dist/src/style/cli-ui.d.ts +14 -0
  44. package/dist/src/style/cli-ui.js +45 -0
  45. package/dist/src/style/cli-ui.js.map +1 -1
  46. package/dist/src/tui/skill-manager.js +1 -1
  47. package/dist/src/tui/skill-manager.js.map +1 -1
  48. package/dist/src/updates/update.js +9 -3
  49. package/dist/src/updates/update.js.map +1 -1
  50. package/package.json +11 -3
  51. package/vendor/academic-paper-skills/LICENSE +21 -0
  52. package/vendor/academic-paper-skills/NOTICE.md +7 -0
  53. package/vendor/academic-paper-skills/PSYCLAW_SOURCE.json +14 -0
  54. package/vendor/academic-paper-skills/academic-paper-composer/SKILL.md +840 -0
  55. package/vendor/academic-paper-skills/academic-paper-composer/references/section_guides.md +675 -0
  56. package/vendor/academic-paper-skills/academic-paper-composer/references/writing_standards.md +629 -0
  57. package/vendor/academic-paper-skills/academic-paper-composer/scripts/chapter_quality_check.py +470 -0
  58. package/vendor/academic-paper-skills/academic-paper-composer/scripts/final_evaluation.py +550 -0
  59. package/vendor/academic-paper-skills/academic-paper-strategist/SKILL.md +670 -0
  60. package/vendor/academic-paper-skills/academic-paper-strategist/references/quality_standards.md +336 -0
  61. package/vendor/academic-paper-skills/academic-paper-strategist/references/search_strategy.md +459 -0
  62. package/vendor/academic-paper-skills/academic-paper-strategist/scripts/evaluate_samples.py +300 -0
  63. package/vendor/academic-paper-skills/academic-paper-strategist/scripts/gap_analysis.py +399 -0
  64. package/vendor/ars/pi/wrapper.js +9 -0
  65. package/vendor/nature-skills/LICENSE +201 -0
  66. package/vendor/nature-skills/NOTICE.md +7 -0
  67. package/vendor/nature-skills/PSYCLAW_SOURCE.json +19 -0
  68. package/vendor/nature-skills/skills/nature-figure/README.md +107 -0
  69. package/vendor/nature-skills/skills/nature-figure/README_EN.md +107 -0
  70. package/vendor/nature-skills/skills/nature-figure/SKILL.md +154 -0
  71. package/vendor/nature-skills/skills/nature-figure/agents/openai.yaml +4 -0
  72. package/vendor/nature-skills/skills/nature-figure/evals/evals.json +325 -0
  73. package/vendor/nature-skills/skills/nature-figure/manifest.yaml +103 -0
  74. package/vendor/nature-skills/skills/nature-figure/references/ai-graphical-abstract-workflow.md +129 -0
  75. package/vendor/nature-skills/skills/nature-figure/references/api.md +576 -0
  76. package/vendor/nature-skills/skills/nature-figure/references/asset-adaptation.md +72 -0
  77. package/vendor/nature-skills/skills/nature-figure/references/backend-selection.md +118 -0
  78. package/vendor/nature-skills/skills/nature-figure/references/chart-types.md +348 -0
  79. package/vendor/nature-skills/skills/nature-figure/references/common-patterns.md +371 -0
  80. package/vendor/nature-skills/skills/nature-figure/references/demos.md +58 -0
  81. package/vendor/nature-skills/skills/nature-figure/references/design-theory.md +467 -0
  82. package/vendor/nature-skills/skills/nature-figure/references/figure-contract.md +122 -0
  83. package/vendor/nature-skills/skills/nature-figure/references/figure-legend-conventions.md +90 -0
  84. package/vendor/nature-skills/skills/nature-figure/references/multipanel-evidence-architecture.md +268 -0
  85. package/vendor/nature-skills/skills/nature-figure/references/nature-2026-observations.md +124 -0
  86. package/vendor/nature-skills/skills/nature-figure/references/nature-article-requirements.md +149 -0
  87. package/vendor/nature-skills/skills/nature-figure/references/openrouter-image-generation.md +141 -0
  88. package/vendor/nature-skills/skills/nature-figure/references/qa-contract.md +344 -0
  89. package/vendor/nature-skills/skills/nature-figure/references/r-template-index.md +66 -0
  90. package/vendor/nature-skills/skills/nature-figure/references/r-workflow.md +234 -0
  91. package/vendor/nature-skills/skills/nature-figure/references/template-catalog.md +33 -0
  92. package/vendor/nature-skills/skills/nature-figure/references/tutorials.md +260 -0
  93. package/vendor/nature-skills/skills/nature-figure/requirements.txt +1 -0
  94. package/vendor/nature-skills/skills/nature-figure/scripts/audit_figure_collisions.py +742 -0
  95. package/vendor/nature-skills/skills/nature-figure/scripts/audit_panel_alignment.py +933 -0
  96. package/vendor/nature-skills/skills/nature-figure/scripts/audit_pdf_text.py +152 -0
  97. package/vendor/nature-skills/skills/nature-figure/scripts/figure_safety.py +50 -0
  98. package/vendor/nature-skills/skills/nature-figure/scripts/generate_openrouter_schematic.py +260 -0
  99. package/vendor/nature-skills/skills/nature-figure/scripts/nature_figure_backend.py +93 -0
  100. package/vendor/nature-skills/skills/nature-figure/scripts/panel_alignment.R +188 -0
  101. package/vendor/nature-skills/skills/nature-figure/scripts/plot_templates.py +604 -0
  102. package/vendor/nature-skills/skills/nature-figure/scripts/validate_figure.py +835 -0
  103. package/vendor/nature-skills/skills/nature-figure/static/core/contract.md +55 -0
  104. package/vendor/nature-skills/skills/nature-figure/static/core/stance.md +41 -0
  105. package/vendor/nature-skills/skills/nature-figure/static/fragments/backend/python.md +56 -0
  106. package/vendor/nature-skills/skills/nature-figure/static/fragments/backend/r.md +63 -0
  107. package/vendor/nature-skills/skills/nature-figure/tests/test_figure_safety.py +209 -0
  108. package/vendor/nature-skills/skills/nature-polishing/README.md +58 -0
  109. package/vendor/nature-skills/skills/nature-polishing/README_EN.md +58 -0
  110. package/vendor/nature-skills/skills/nature-polishing/SKILL.md +111 -0
  111. package/vendor/nature-skills/skills/nature-polishing/agents/openai.yaml +4 -0
  112. package/vendor/nature-skills/skills/nature-polishing/manifest.yaml +101 -0
  113. package/vendor/nature-skills/skills/nature-polishing/references/latex-layout.md +211 -0
  114. package/vendor/nature-skills/skills/nature-polishing/references/nat-comms-2025-diction.md +73 -0
  115. package/vendor/nature-skills/skills/nature-polishing/references/phrasebank-playbook.md +175 -0
  116. package/vendor/nature-skills/skills/nature-polishing/references/published-article-patterns.md +126 -0
  117. package/vendor/nature-skills/skills/nature-polishing/references/section-moves.md +252 -0
  118. package/vendor/nature-skills/skills/nature-polishing/references/style-guardrails.md +94 -0
  119. package/vendor/nature-skills/skills/nature-polishing/references/writing-strategy.md +160 -0
  120. package/vendor/nature-skills/skills/nature-polishing/static/core/failure-modes.md +29 -0
  121. package/vendor/nature-skills/skills/nature-polishing/static/core/output-format.md +21 -0
  122. package/vendor/nature-skills/skills/nature-polishing/static/core/stance.md +26 -0
  123. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/generic.md +17 -0
  124. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nat-comms.md +38 -0
  125. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nat-mach-intell.md +102 -0
  126. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nature.md +19 -0
  127. package/vendor/nature-skills/skills/nature-polishing/static/fragments/language/en.md +19 -0
  128. package/vendor/nature-skills/skills/nature-polishing/static/fragments/language/zh-to-en.md +19 -0
  129. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/algorithmic.md +18 -0
  130. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/hypothesis.md +17 -0
  131. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/methods.md +35 -0
  132. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/research.md +29 -0
  133. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/review.md +17 -0
  134. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/abstract.md +26 -0
  135. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/conclusion.md +15 -0
  136. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/discussion.md +48 -0
  137. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/intro.md +33 -0
  138. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/methods.md +26 -0
  139. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/results.md +61 -0
  140. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/title.md +17 -0
  141. package/vendor/nature-skills/skills/nature-ref-verifier/README.md +44 -0
  142. package/vendor/nature-skills/skills/nature-ref-verifier/README_EN.md +44 -0
  143. package/vendor/nature-skills/skills/nature-ref-verifier/SKILL.md +196 -0
  144. package/vendor/nature-skills/skills/nature-ref-verifier/agents/openai.yaml +4 -0
  145. package/vendor/nature-skills/skills/nature-ref-verifier/manifest.yaml +19 -0
  146. package/vendor/nature-skills/skills/nature-ref-verifier/references/common-patterns.md +96 -0
  147. package/vendor/nature-skills/skills/nature-shared/README.md +43 -0
  148. package/vendor/nature-skills/skills/nature-shared/README_EN.md +43 -0
  149. package/vendor/nature-skills/skills/nature-shared/SKILL.md +33 -0
  150. package/vendor/nature-skills/skills/nature-shared/agents/openai.yaml +6 -0
  151. package/vendor/nature-skills/skills/nature-shared/core/consistency-sweep.md +122 -0
  152. package/vendor/nature-skills/skills/nature-shared/core/discussion-argument-language.md +192 -0
  153. package/vendor/nature-skills/skills/nature-shared/core/ethics.md +88 -0
  154. package/vendor/nature-skills/skills/nature-shared/core/main-text-discipline.md +179 -0
  155. package/vendor/nature-skills/skills/nature-shared/core/nature-abstract.md +171 -0
  156. package/vendor/nature-skills/skills/nature-shared/core/nature-introduction.md +164 -0
  157. package/vendor/nature-skills/skills/nature-shared/core/nature-results-discussion.md +215 -0
  158. package/vendor/nature-skills/skills/nature-shared/core/paper-type-taxonomy.md +41 -0
  159. package/vendor/nature-skills/skills/nature-shared/core/reader-workflow.md +21 -0
  160. package/vendor/nature-skills/skills/nature-shared/core/research-compliance.md +192 -0
  161. package/vendor/nature-skills/skills/nature-shared/core/terminology-ledger.md +58 -0
  162. package/vendor/nature-skills/skills/nature-shared/journal-formats/nat-comms.md +139 -0
  163. package/vendor/nature-skills/skills/nature-shared/journal-formats/nature-machine-intelligence.md +431 -0
  164. package/vendor/nature-skills/skills/nature-shared/journal-formats/nature.md +313 -0
  165. package/vendor/nature-skills/skills/nature-shared/manifest.yaml +52 -0
  166. package/vendor/nature-skills/skills/nature-shared/scripts/check_consistency.py +273 -0
  167. package/vendor/nature-skills/skills/nature-shared/tests/test_check_consistency.py +63 -0
@@ -0,0 +1,467 @@
1
+ # Nature Figure Design Theory
2
+
3
+ ## Contents
4
+
5
+ - [1) Typography](#1-typography)
6
+ - [2) Axes & Spines](#2-axes-spines)
7
+ - [3) Color Palette](#3-color-palette)
8
+ - [4) Layout and Composition](#4-layout-and-composition)
9
+ - [5) Bar Chart Rules](#5-bar-chart-rules)
10
+ - [6) Line / Trend Plots](#6-line-trend-plots)
11
+ - [7) Heatmap Rules](#7-heatmap-rules)
12
+ - [8) Radar / Polar Charts](#8-radar-polar-charts)
13
+ - [9) Export Policy](#9-export-policy)
14
+ - [10) Multi-Panel Information Architecture](#10-multi-panel-information-architecture)
15
+ - [11) Reproduction Checklist](#11-reproduction-checklist)
16
+
17
+
18
+ This file is an original synthesis of publication-figure typography, color,
19
+ composition, and export rules. External repositories may be consulted only as
20
+ visual references after their license and reuse terms have been verified; see
21
+ [demos.md](demos.md).
22
+
23
+ ---
24
+
25
+ ## 1) Typography
26
+
27
+ ### Font stack (priority order)
28
+ - **Nature standard**: `font.family = 'sans-serif'`, `font.sans-serif = ['Arial']`
29
+ - **Fallback stack**: `['Arial', 'Helvetica', 'DejaVu Sans', 'sans-serif']`
30
+ - **Helvetica** (equivalent) also appears in many scripts as `font.family = 'helvetica'`
31
+ - SVG/PDF editable text: always set `svg.fonttype = 'none'`
32
+ - LaTeX math labels: `text.usetex = True` only when LaTeX is installed
33
+
34
+ ### Font size hierarchy
35
+ | Context | font.size | axes.linewidth |
36
+ |---------|-----------|---------------|
37
+ | Journal-final dense multi-panel figure at publication width | 7–9 | 0.8–1.2 |
38
+ | Large comparison bar panels (figsize > 28in wide) | 24 | 3 |
39
+ | Compact subfigures / analytic plots | 15–16 | 2 |
40
+ | Axis labels on large panels | 32–54 (override per-label) | — |
41
+ | In-bar annotations | 32–36 | — |
42
+ | Legend text on large panels | 28–38 | — |
43
+ | Tick labels | 20–36 | — |
44
+
45
+ When targeting the final dimensions of a two-column `Nature` figure page, start smaller than
46
+ slide-sized preview figures. The sampled 2026 papers routinely landed in the `7–9 pt` final-text
47
+ regime for dense composites.
48
+
49
+ The submission floor applies to rendered glyphs, not only source-level parent sizes. Mathtext often scales scripts to about `0.7×`; a 7 pt `$R^2$` can therefore contain a 4.9 pt superscript. Prefer a supported Unicode glyph such as `R²` when appropriate, or raise the parent size and verify the exported PDF with `scripts/audit_pdf_text.py`. Also compare each long label's rendered bounding-box width with its allocated slot width in millimetres.
50
+
51
+ ---
52
+
53
+ ## 2) Axes & Spines
54
+
55
+ ```python
56
+ plt.rcParams['axes.spines.right'] = False # always off
57
+ plt.rcParams['axes.spines.top'] = False # always off
58
+ plt.rcParams['legend.frameon'] = False # frameless legends everywhere
59
+ ```
60
+
61
+ - Keep only left + bottom spines — minimalist, Nature-approved.
62
+ - No grid lines by default; use sparse y-ticks to guide the eye.
63
+
64
+ ---
65
+
66
+ ## 3) Color Palette
67
+
68
+ Semantic: blue = proposed method, green = positive variants, red/pink = baselines, neutral = reference/background.
69
+ For dense multi-panel figures, however, **family consistency beats maximal hue separation**.
70
+
71
+ ```python
72
+ PALETTE = {
73
+ # Proposed / key method
74
+ "blue_main": "#0F4D92", # deep blue — hero method
75
+ "blue_secondary": "#3775BA", # medium blue — second author method
76
+
77
+ # Positive / improvement shades (light → dark)
78
+ "green_1": "#DDF3DE",
79
+ "green_2": "#AADCA9",
80
+ "green_3": "#8BCF8B",
81
+
82
+ # Baseline / contrast shades (light → dark)
83
+ "red_1": "#F6CFCB",
84
+ "red_2": "#E9A6A1",
85
+ "red_strong": "#B64342",
86
+
87
+ # Neutral support
88
+ "neutral_light": "#CFCECE",
89
+ "neutral_mid": "#767676",
90
+ "neutral_dark": "#4D4D4D",
91
+ "neutral_black": "#272727",
92
+
93
+ # Accent / callout (use sparingly)
94
+ "gold": "#FFD700",
95
+ "teal": "#42949E",
96
+ "violet": "#9A4D8E",
97
+ "magenta":"#EA84DD",
98
+ }
99
+
100
+ DEFAULT_COLOR_ORDER = [
101
+ "#0F4D92", # blue_main
102
+ "#8BCF8B", # green_3
103
+ "#B64342", # red_strong
104
+ "#42949E", # teal
105
+ "#9A4D8E", # violet
106
+ "#CFCECE", # neutral_light
107
+ ]
108
+ ```
109
+
110
+ ### Unified-family rule (recommended for NMI-style pages)
111
+
112
+ Publication figures should read like **one figure**, not six unrelated plots. Prefer one cool family for
113
+ baselines and one lilac/rose family for the proposed method line.
114
+
115
+ ```python
116
+ PALETTE_NMI_PASTEL = {
117
+ "baseline_dark": "#484878",
118
+ "baseline_mid": "#7884B4",
119
+ "baseline_soft": "#B4C0E4",
120
+ "ours_tiny": "#E4E4F0",
121
+ "ours_base": "#E4CCD8",
122
+ "ours_large": "#F0C0CC",
123
+ "delta_up": "#2E9E44",
124
+ "delta_down": "#E53935",
125
+ }
126
+
127
+ DEFAULT_COLOR_ORDER_NMI_PASTEL = [
128
+ "#484878", # baseline_dark
129
+ "#7884B4", # baseline_mid
130
+ "#B4C0E4", # baseline_soft
131
+ "#E4E4F0", # ours_tiny
132
+ "#E4CCD8", # ours_base
133
+ "#F0C0CC", # ours_large
134
+ ]
135
+ ```
136
+
137
+ Rules:
138
+ 1. Keep related baselines in one cool family.
139
+ 2. Keep `Tiny / Base / Large` or sibling variants in one hero family.
140
+ 3. Reserve green/red for arrows, gains, drops, thresholds, or signed biological direction.
141
+ 4. Never remap the same method to a different hue family in another panel.
142
+ 5. If in doubt, reduce saturation before adding more categories.
143
+ 6. Validate pairwise separation and white-background contrast, then inspect rendered salience. A neutral baseline must not dominate the hero method merely because it is darker.
144
+ 7. Sequential light-to-dark scales encode order or magnitude; do not treat their steps as unrelated categories.
145
+
146
+ ### Modality-specific palette discipline from sampled 2026 Nature figures
147
+
148
+ - **Imaging plates**: grayscale context + 1–2 fluorescent accent channels on black.
149
+ - **Schematic/material pages**: derive the palette from the physical objects in the schematic,
150
+ then reuse softened versions of those colors in the support plots.
151
+ - **Clinical composites**: dark baseline/reference series, restrained warm/cool follow-up hues,
152
+ pale background bands in forest plots.
153
+ - **Genomics / systems pages**: neutral grey scaffolds plus a small number of biologically
154
+ meaningful highlight families, often one red and one blue.
155
+
156
+ ### Ablation alpha encoding
157
+ When ablating components of one method, use a **single color with varying alpha**:
158
+ ```python
159
+ color = (0.215686, 0.458824, 0.729412) # blue_secondary as RGB tuple
160
+ alphas = np.linspace(0.2, 1.0, n_variants)
161
+ colors = [(color[0], color[1], color[2], a) for a in alphas]
162
+ # alpha=1.0 → full method, alpha=0.2 → minimal/ablated variant
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 4) Layout and Composition
168
+
169
+ ### Figure sizes
170
+ | Figure type | Typical figsize |
171
+ |-------------|----------------|
172
+ | Journal-width composite page / asymmetric multi-panel | (7.0–7.4, 5.5–7.8) |
173
+ | Multi-metric bar (3–4 metrics + legend) | (28–45, 6–12) |
174
+ | Compact single bar | (9–16, 5–8) |
175
+ | Trend / line multi-panel | (14, 4) or (9, 8) |
176
+ | Heatmap single | (8–20, 5–9) |
177
+ | Radar polar | (12, 10) |
178
+ | 3D / illustration multi-panel | (24, 8) |
179
+
180
+ **Rule**: Width ≈ 3–4× height for comparison bars; prevents vertical crowding and allows left-to-right narrative reading.
181
+
182
+ ### Dedicated legend panel
183
+ For multi-axis figures, the **last subplot is legend-only**:
184
+ ```python
185
+ ax_legend = fig.add_subplot(1, n+1, n+1)
186
+ ax_legend.legend(handles, labels, fontsize=..., loc='center', frameon=False)
187
+ ax_legend.set_axis_off()
188
+ ```
189
+
190
+ ### Dynamic y-axis scaling
191
+ Never use fixed 0–100 when values sit in a narrow band.
192
+ Tighten limits to data range: e.g., `ax.set_ylim([data.min() - margin, data.max() + margin])`.
193
+
194
+ ### Nature page archetypes from sampled 2026 papers
195
+
196
+ `Nature` figures were not uniformly dashboard-like. They repeatedly used a few strong page
197
+ archetypes:
198
+
199
+ | Archetype | Layout signal | Practical rule |
200
+ |-----------|---------------|----------------|
201
+ | Schematic-led composite | One wide story panel with smaller quant panels below | Give the schematic the visual hierarchy; supporting plots should validate, not compete |
202
+ | Dark image plate | Repeated black tiles with fluorescent channels | Use black only inside the image plate region; keep scale bars, gutters, and channel labels high-contrast |
203
+ | Clinical triptych | Top longitudinal row, middle forest row, bottom summary row | Reuse the same column logic across outcomes and put the shared legend above the row |
204
+ | Asymmetric hero layout | One dominant circular/schematic panel plus small support plots | Let one panel span multiple grid cells; equal panel sizes are not required |
205
+
206
+ ### Panel labels and gutters
207
+
208
+ - Use small bold lowercase panel letters near the top-left edge.
209
+ - Keep gutters tight but real; increase spacing when dark and light modalities touch.
210
+ - Leave extra bottom clearance when a dense caption will sit immediately below the figure.
211
+ - Avoid decorative panel boxes. Alignment and whitespace should carry the structure.
212
+
213
+ ### Legend economy and direct labelling
214
+
215
+ - Use direct labels when regions, channels, or line identities are spatially stable.
216
+ - Prefer one shared legend strip above a row rather than repeating legends inside several axes.
217
+ - Dense categorical area plots often read better with embedded text than with a detached legend.
218
+ - If a legend exists, it should usually be frameless and visually quieter than the data.
219
+ - Measure legend/panel and legend-row spacing from their rendered tight bounding boxes. Do not infer spacing from a full raster row when the objects occupy different horizontal positions.
220
+ - Check long model names at final size against the width allocated to each group. Widen the layout or reduce text size while keeping every PDF glyph at least 5 pt.
221
+
222
+ ### X-tick suppression
223
+ When bars represent methods and the legend already names them:
224
+ ```python
225
+ ax.set_xticks([]) # hide x-tick labels; use legend + panel title instead
226
+ ```
227
+
228
+ ---
229
+
230
+ ## 5) Bar Chart Rules
231
+
232
+ ### Vertical bars (comparison)
233
+ ```python
234
+ bars = ax.bar(
235
+ x_positions,
236
+ values,
237
+ yerr=std_values,
238
+ capsize=5,
239
+ color=colors,
240
+ label=method_names,
241
+ edgecolor='black', # sharp separation
242
+ linewidth=1.5,
243
+ )
244
+ ```
245
+
246
+ ### Horizontal bars (ablation)
247
+ ```python
248
+ ax.barh(
249
+ y_positions,
250
+ values,
251
+ xerr=std_values,
252
+ color=[(r, g, b, alpha) for alpha in alphas],
253
+ ecolor='k',
254
+ capsize=5,
255
+ )
256
+ ```
257
+
258
+ ### In-bar value annotation
259
+ Print exact numbers inside or above bars at 32–36pt for readability without a grid:
260
+ ```python
261
+ for bar, value in zip(bars, values):
262
+ luminance = compute_luminance(bar_color)
263
+ textcolor = 'white' if luminance < 128 else 'black'
264
+ ax.text(bar.get_x() + bar.get_width()/2,
265
+ bar.get_height() - 0.10,
266
+ f'{value:.2f}',
267
+ ha='center', va='bottom',
268
+ fontsize=32, color=textcolor)
269
+ ```
270
+
271
+ ### Hatch encoding for print-safe grayscale
272
+ ```python
273
+ hatches = ['/', '\\', '.', 'x', 'o']
274
+ for bar, hatch in zip(bars, hatches):
275
+ bar.set_hatch(hatch)
276
+ ```
277
+
278
+ ### Error bar styling
279
+ ```python
280
+ error_kw = {
281
+ 'elinewidth': 2,
282
+ 'capthick': 2,
283
+ 'capsize': 15,
284
+ }
285
+ ```
286
+
287
+ ---
288
+
289
+ ## 6) Line / Trend Plots
290
+
291
+ - Line width: 2–3pt with controlled alpha.
292
+ - Marker size: 8–12pt circles.
293
+ - For clinical or longitudinal triptychs, place one shared legend above the row rather than repeating it per axis.
294
+ - Fading alpha for temporal progression:
295
+ ```python
296
+ from matplotlib.collections import LineCollection
297
+ alphas = np.linspace(0.3, 0.9, n_segments)
298
+ # build LineCollection with per-segment alpha
299
+ ```
300
+ - `fill_between` for uncertainty bands (keep alpha low: 0.1–0.2).
301
+ - If comparable panels summarize the same seed/fold/split process, show the same spread definition in all of them. After adding uncertainty, remove arrows or brackets that duplicate the same visual gap and collide with the interval geometry.
302
+ - Reference baseline as dashed horizontal line: `ax.axhline(y=..., linestyle='--', alpha=0.3, linewidth=4)`.
303
+ - No grid; sparse y-ticks guide the eye.
304
+
305
+ ---
306
+
307
+ ## 7) Heatmap Rules
308
+
309
+ ```python
310
+ import matplotlib as mpl
311
+
312
+ # Diverging (positive/negative): use Red + Blue colormaps per column direction
313
+ cmap_pos = plt.cm.Reds
314
+ cmap_neg = plt.cm.Blues_r
315
+
316
+ # Masked NaN cells show as white
317
+ cmap.set_bad(color='white')
318
+
319
+ # Normalize per column
320
+ norm = mpl.colors.Normalize(vmin=col_min, vmax=col_max)
321
+
322
+ # Remove frame
323
+ ax.set_frame_on(False)
324
+
325
+ # Remove tick marks, keep labels
326
+ ax.tick_params(axis='x', which='both', bottom=False, top=False, length=0)
327
+ ```
328
+
329
+ Cell text contrast:
330
+ ```python
331
+ r, g, b, _ = cmap(norm(value))
332
+ luminance = 0.299*r + 0.587*g + 0.114*b
333
+ text_color = 'white' if luminance < 0.5 else 'black'
334
+ ```
335
+
336
+ ---
337
+
338
+ ## 8) Radar / Polar Charts
339
+
340
+ - Project: `fig.add_subplot(projection='polar')`.
341
+ - Remove default grid and spines; draw custom spokes and contour polygons.
342
+ - Normalize per-spoke to display range (e.g., 45–90) using per-benchmark tick lists.
343
+ - Use `ax.set_theta_zero_location('N')` to start at top.
344
+ - Legend: `bbox_to_anchor=(1.40, 0.05)` outside right edge.
345
+
346
+ ---
347
+
348
+ ## 9) Export Policy
349
+
350
+ ### SVG is the required primary format
351
+
352
+ SVG preserves editable text (when `svg.fonttype = 'none'`), supports lossless scaling,
353
+ and is required for any figure where text labels may need post-hoc alignment in
354
+ Illustrator or Inkscape. Always save SVG first.
355
+
356
+ ```python
357
+ import os
358
+ os.makedirs('./figures/', exist_ok=True)
359
+ fig.tight_layout(pad=2) # default; use pad=1 for compact multi-panel
360
+
361
+ # ── PRIMARY ── editable vector, text as <text> nodes ─────────────────────────
362
+ fig.savefig('./figures/name.svg', bbox_inches='tight')
363
+
364
+ # ── SECONDARY ── raster for quick preview / submission portals ────────────────
365
+ fig.savefig('./figures/name.png', dpi=300, bbox_inches='tight')
366
+
367
+ plt.close(fig) # always close to free memory
368
+ ```
369
+
370
+ **DPI guide (PNG only)**:
371
+ - `dpi=300` — standard for all figure types.
372
+ - `dpi=600` — dense bar panels with many methods.
373
+
374
+ **Never** use `svg.fonttype = 'path'` (matplotlib default): it converts glyphs to bezier
375
+ curves, breaking text editability. The mandatory three rcParams lines (see api.md) must
376
+ be set before any `savefig` call.
377
+
378
+ ---
379
+
380
+ ## 10) Multi-Panel Information Architecture
381
+
382
+ ### Rule: Every panel must answer a unique scientific question
383
+
384
+ In a multi-panel figure, each panel should be independently necessary but need
385
+ not tell an independent story. Covering one panel must remove a distinct
386
+ inferential step that cannot be recovered from the others. For figure-level
387
+ claim design, evidence-role selection, placement decisions and manuscript
388
+ figure progression, load `multipanel-evidence-architecture.md`.
389
+
390
+ **Recommended three-level progression**:
391
+
392
+ | Level | Question answered | Typical encoding |
393
+ |-------|------------------|-----------------|
394
+ | Overview | "What is the landscape?" | Stacked bar, composition |
395
+ | Deviation | "What is distinctive per group?" | Z-score heatmap (diverging cmap) |
396
+ | Relationship | "How do variables co-vary?" | Scatter / bubble plot |
397
+
398
+ ### Anti-redundancy checklist
399
+
400
+ Before finalising:
401
+
402
+ - [ ] Panel b does **not** re-display the same data as panel a in a different visual form
403
+ - [ ] Panel c adds a dimension absent from a and b (e.g., correlation, biological relationship)
404
+ - [ ] Each panel has its own axis-label vocabulary (different x/y quantities)
405
+
406
+ ### Common redundancy traps
407
+
408
+ | Trap | Example | Fix |
409
+ |------|---------|-----|
410
+ | Absolute + absolute | Stacked bar (%) + heatmap of same % | Replace heatmap with z-score deviation |
411
+ | Subset of parent | Tumor-only ranked bar is just one column of the stacked bar | Swap for scatter: tumor % vs. immune % |
412
+ | Two rankings | Two ranked bars on related metrics | Replace one with scatter / bubble |
413
+ | Different chart, same data slice | Pie + stacked bar | Merge or replace one with a relationship plot |
414
+
415
+ ### Z-score deviation heatmap (complement to a composition bar)
416
+
417
+ When panel a shows absolute composition, panel b should show **what is atypical** per group:
418
+
419
+ ```python
420
+ # heat: DataFrame (cohorts × cell-type categories), values in %
421
+ z = (heat - heat.mean(axis=0)) / heat.std(axis=0)
422
+ im = ax.imshow(z.values, cmap="RdBu_r", aspect="auto", vmin=-2.5, vmax=2.5)
423
+ # colorbar label:
424
+ cbar.set_label("Z-score vs pan-cohort mean")
425
+ ```
426
+
427
+ Use `RdBu_r` (red = enriched above average, blue = depleted). This diverging view is orthogonal to the absolute-percentage view in panel a.
428
+
429
+ ### Bubble scatter (complement to both)
430
+
431
+ When a = composition, b = deviation, panel c should reveal **biological co-variation**:
432
+
433
+ ```python
434
+ # x: dominant compartment (e.g., tumor %)
435
+ # y: functional readout (e.g., immune-cell %)
436
+ # size: third variable (e.g., stroma %)
437
+ ax.scatter(x, y, s=stroma * scale, c=colors,
438
+ edgecolors="white", linewidth=0.8, alpha=0.9)
439
+ # Quadrant reference lines at median x and median y
440
+ ax.axvline(np.median(x), lw=1.2, ls="--", color="#767676", alpha=0.6)
441
+ ax.axhline(np.median(y), lw=1.2, ls="--", color="#767676", alpha=0.6)
442
+ ```
443
+
444
+ Label quadrants ("Immune-hot / low tumor", "Immune-desert / high tumor", …) with small grey text.
445
+
446
+ ---
447
+
448
+ ## 11) Reproduction Checklist
449
+
450
+ To match Nature publication standards:
451
+
452
+ - [ ] **MANDATORY first lines**: `font.family='sans-serif'`, `font.sans-serif=['Arial','DejaVu Sans','Liberation Sans']`, `svg.fonttype='none'`
453
+ - [ ] **Save as SVG** (primary). PNG dpi=300 as optional raster preview.
454
+ - [ ] Top and right spines off; frameless legend
455
+ - [ ] Figure architecture chosen intentionally: grid, schematic-led composite, image plate, or asymmetric hero layout
456
+ - [ ] Journal-final source fonts usually 7–9 pt, and every exported PDF glyph including scripts is ≥ 5 pt
457
+ - [ ] Colors from blue-green-red-neutral semantic palette
458
+ - [ ] Rendered salience hierarchy matches the evidence hierarchy; neutral baselines do not dominate hero evidence
459
+ - [ ] Black background used only for imaging plates, not for ordinary plots
460
+ - [ ] Legends omitted or shared when direct labels or one legend strip read better
461
+ - [ ] Y-limits tightened to data range (not 0–100 when values are 80–95)
462
+ - [ ] X-ticks hidden when methods are named in legend
463
+ - [ ] Legend in dedicated panel or `frameon=False`
464
+ - [ ] Every comparable stochastic aggregate panel has the intended uncertainty definition
465
+ - [ ] Rotated text uses anchor placement; labels clear data and uncertainty without opaque masks
466
+ - [ ] `tight_layout(pad=2)` before save
467
+ - [ ] `plt.close(fig)` after save
@@ -0,0 +1,122 @@
1
+ # Figure Contract
2
+
3
+ Use this reference before writing plotting code. The goal is to make the figure
4
+ serve the paper's scientific logic.
5
+
6
+ ## Contents
7
+
8
+ - [Privacy rule](#privacy-rule)
9
+ - [Required contract](#required-contract)
10
+ - [Core conclusion rules](#core-conclusion-rules)
11
+ - [Archetype selection](#archetype-selection)
12
+ - [Panel logic](#panel-logic)
13
+ - [Aesthetic integration](#aesthetic-integration)
14
+ - [Reviewer-risk prompts](#reviewer-risk-prompts)
15
+
16
+ ## Privacy rule
17
+
18
+ Keep the figure contract user-facing, but keep the working trail private. Do not mention
19
+ private paths, source filenames, internal reference documents, template identifiers, or
20
+ where a private draft came from unless the user explicitly asks for provenance.
21
+
22
+ ## Required contract
23
+
24
+ Create a short contract in working notes or in the response:
25
+
26
+ ```text
27
+ Core conclusion:
28
+ Results-level question:
29
+ Figure archetype:
30
+ Target journal/output:
31
+ Backend: Python or R
32
+ Final size:
33
+ Panel map:
34
+ a:
35
+ b:
36
+ c:
37
+ Evidence hierarchy:
38
+ hero evidence:
39
+ validation evidence:
40
+ controls/robustness:
41
+ Statistics needed:
42
+ Source data needed:
43
+ Image-integrity notes:
44
+ Reviewer risk:
45
+ ```
46
+
47
+ Do not start from a favorite template. Start from the conclusion, then choose the
48
+ minimum set of panels that make the conclusion clear and defensible.
49
+
50
+ Do not start by mapping each input table to a figure. First group tables, metrics,
51
+ and experiments by the scientific claims they can support. Several source tables
52
+ may belong in one evidence chain, while one table may support multiple distinct
53
+ panels. This claim-first pass prevents redundant figures that restate the same result.
54
+
55
+ ## Core conclusion rules
56
+
57
+ - The core conclusion should be one sentence with a verb: "Treatment X reduces
58
+ Y by restoring Z", not "Treatment results".
59
+ - Every panel must answer a unique question. If covering a panel would not weaken
60
+ the argument, remove or merge it.
61
+ - Separate primary evidence from supporting evidence. The primary evidence gets
62
+ the hero panel or the clearest axis; controls and robustness panels should be
63
+ visually quieter.
64
+ - If the user provides data but no claim, infer a provisional claim from the data
65
+ request. Confirm only an unresolved interpretive claim that materially changes the final figure; continue independent data checks and layout preparation while waiting. Do not add unsupported causal claims.
66
+ - If observations are matched by dataset, subject, seed, task, or specimen, decide
67
+ whether the claim concerns the paired change. Marginal distributions can overlap
68
+ because of between-unit heterogeneity even when paired differences are consistent.
69
+
70
+ ## Archetype selection
71
+
72
+ | Archetype | Use when | Hero panel | Supporting panels |
73
+ |---|---|---|---|
74
+ | `quantitative grid` | The claim is mainly numerical comparison | Optional; often a dominant summary metric | Shared axes, aligned scales, compact legends |
75
+ | `schematic-led composite` | A workflow, mechanism, device, or experimental design must be understood first | Left or top schematic, 35-60% of area | 2-4 quantitative validation panels |
76
+ | `image plate + quant` | Microscopy, imaging, histology, spatial overlays, segmentation, or blots lead the evidence | Image plate or representative image | Scale bars, overlays, crops, quantification |
77
+ | `asymmetric mixed-modality figure` | The figure combines schematic, raster images, heatmaps, and quantitative plots | One panel spans rows/columns | Smaller panels ranked by evidence value |
78
+
79
+ ## Panel logic
80
+
81
+ For a labelled multi-panel manuscript figure, load
82
+ `multipanel-evidence-architecture.md`. Use `one figure = one major claim` as a
83
+ strong planning default. Panels should be different necessary sentences in the
84
+ same visual argument, not parallel mini-stories or the same comparison mirrored
85
+ across several metrics.
86
+
87
+ Use this order unless the manuscript story clearly requires another:
88
+
89
+ 1. Establish the system: sample, method, cohort, device, or experimental design.
90
+ 2. Show the main effect or primary comparison.
91
+ 3. Show mechanism or localization.
92
+ 4. Quantify the representative image or qualitative observation.
93
+ 5. Add robustness, controls, subgroup analysis, or sensitivity analysis.
94
+
95
+ For Fig. 1 or a method figure, the first panel often defines the visual vocabulary:
96
+ colors, symbols, workflow direction, sample classes, and scale. Reuse that vocabulary
97
+ through the whole figure and, where possible, through the manuscript.
98
+
99
+ ## Aesthetic integration
100
+
101
+ - Use one neutral family, one signal family, and one accent family.
102
+ - Keep the same condition/method color across all panels.
103
+ - Prefer direct labels for stable line identities, channels, and fixed spatial regions.
104
+ - Use a shared legend area when repeated legends would waste space.
105
+ - Avoid equal-sized panels when the evidence is not equally important.
106
+ - Keep schematic colors and quantitative plot colors related. A schematic-led
107
+ figure should look like one integrated argument, not a pasted collage.
108
+
109
+ ## Reviewer-risk prompts
110
+
111
+ Before finalizing, ask what a skeptical reviewer would challenge:
112
+
113
+ - Is the sample size visible in the legend or source data?
114
+ - Are error bars, intervals, and statistical tests defined?
115
+ - Are the same uncertainty definitions present in every comparable aggregate panel?
116
+ - Are axes comparable across panels that invite comparison?
117
+ - Would a paired-difference view reveal an effect hidden by overlapping marginal distributions?
118
+ - Does each legend label preserve canonical capitalization and match the terminology plan?
119
+ - Do data labels clear the upper uncertainty extent at final rendered size?
120
+ - Are representative images quantified and traceable to raw files?
121
+ - Are image adjustments global and documented?
122
+ - Could the same conclusion be made from fewer panels?
@@ -0,0 +1,90 @@
1
+ # Figure & Table Legend Conventions (Nat Commun 2025 CS/AI corpus)
2
+
3
+ Use this file when **writing or auditing the legend text** of a figure or table.
4
+ It complements `nature-2026-observations.md`, which covers visual/layout
5
+ archetypes; this file covers the *words* of the caption. Distilled from a 2025
6
+ set of 20 open-access *Nature Communications* computer-science / AI papers
7
+ (legend conventions were consistent across all research articles). **Do not copy
8
+ source wording.**
9
+
10
+ ## Legend structure — the fixed skeleton
11
+
12
+ 1. **`Fig. N | ` + a bold noun-phrase overall title** that names the whole
13
+ figure. Common openers: *Overview of …*, *Comparison of …*, *Performance of
14
+ …*, or a finding phrase. No terminal full stop required on the title.
15
+ 2. **`a / b / c …` panels, each described in present tense, telegraphic style**,
16
+ often subject-less: *"a Comparison of the four EMS paradigms. b Distributions
17
+ of WSIs and patches in the pre-training dataset."*
18
+ 3. **Statistics written into the legend**: sample size `n=`, error type, and
19
+ test — *"mean ± 95% CI (n = 1373) … one-way ANOVA with Tukey correction."*
20
+ 4. **Data-availability boilerplate** at the end: *"Source data are provided as a
21
+ Source Data file."*
22
+
23
+ ## Tense
24
+
25
+ - Visual facts in **present** tense — *"are shown as cyan sticks"*, *"depicts"*.
26
+ - Methods/how-it-was-made in **past** tense — *"was performed"*, *"was adopted
27
+ from"*.
28
+
29
+ ## Self-containment rule
30
+
31
+ A legend must be readable away from the body text. Put colour/shape mappings,
32
+ sample size, and key numeric anchors (PDB id, RMSD, units) into the legend
33
+ itself — *"tRNA-Glu of E. coli (PDB: 2DER chain C). 76 nt, RMSD: 2.88 Å."*;
34
+ *"Grey boxes designate what is defined by the benchmark, and orange boxes
35
+ indicate what is unique to each solution."*
36
+
37
+ ## Display-label capitalization
38
+
39
+ - Treat in-figure legend entries as display labels. Start ordinary descriptive labels with an uppercase letter, for example `Tuned XGBoost`, `Tuned RF`, `+ Semantic guidance`, and `+ Causal guidance`.
40
+ - Preserve canonical product/model spelling exactly, including internal capitals, hyphens, periods, and abbreviations such as `XGBoost`, `DeepSeek`, `GPT-5.2`, and `RF`.
41
+ - In prose legend sentences, use normal sentence grammar rather than forcing every term into display case.
42
+ - Do not apply `.title()` or equivalent automatic title-casing because it corrupts canonical names.
43
+
44
+ ## Advanced: the claim-closing sentence
45
+
46
+ A legend's final sentence may advance an argument rather than only describe —
47
+ *"…indicating that these co-folding models are not predicting poses based on
48
+ physics but rather learning patterns in global structures."* Use sparingly, and
49
+ only when the panel actually supports the inference.
50
+
51
+ ## Review/Perspective legends
52
+
53
+ When a figure aggregates others' published systems, each sub-panel gets a
54
+ one-line characterisation (often past tense, describing prior work) and the
55
+ legend carries an attribution line — *"adapted with permission from refs. 16,17
56
+ … by Springer Nature."* Include the permission/attribution string for any
57
+ adapted panel.
58
+
59
+ ## Table captions
60
+
61
+ Same shape: **`Table N | ` + noun phrase**, with detailed specs pointed to
62
+ Methods — *"Table 1 | … Detailed specifications are provided in the Methods
63
+ section."* Benchmark/framework papers lean on tables (multi-metric results) more
64
+ than figures.
65
+
66
+ ## Length and journal gate
67
+
68
+ - This file's corpus evidence is from Nature Communications and does not set a
69
+ universal Nature Portfolio word limit.
70
+ - For the flagship journal Nature, load `nature-article-requirements.md` and
71
+ keep each complete figure legend below 250 words.
72
+ - For Nature Machine Intelligence, load the shared NMI contract. Its current
73
+ live pages give no standalone per-legend number, while its official 2018
74
+ brief guide said to keep each figure legend below 300 English words. Count
75
+ the complete title-plus-panels legend, not each panel; aim for 150–250 words
76
+ and use below 300 as a historical advisory ceiling unless the live submission
77
+ system or editor gives a newer instruction.
78
+ - For Nature Communications or another subjournal, verify the current journal
79
+ and article-type instructions before enforcing a numerical cap.
80
+ - Keep the `Fig. N |` title short and nominal; no numbers/results in the figure
81
+ *title* line (numbers live in the panels and stats).
82
+
83
+ ## 中文图注要点
84
+
85
+ - 结构铁律:`图 N | 加粗名词短语总题` → `a/b/c` 现在时电报式分面 → 统计(n、误差、检验)写进图注 → "Source data are provided as a Source Data file." 套语。
86
+ - 时态:视觉事实用现在时,制作方法用过去时。
87
+ - 自足:颜色/形状映射、样本量、关键数值(PDB/RMSD/单位)都写进图注,使其脱离正文可读。
88
+ - 图内图例按展示标签处理,普通描述首字母大写,同时保留 `XGBoost`、`DeepSeek`、`GPT-5.2`、`RF` 等规范拼写;正文仍按句法大小写,不要盲目自动 title case。
89
+ - 进阶:图注末句可给一句推断结论,但须确有面板支撑。
90
+ - 综述图注:聚合他人系统时逐子图一句话定性,并标注"adapted with permission from refs… by Springer Nature"授权。