evalrx 0.1.2__py3-none-any.whl

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 (339) hide show
  1. evalrx/__init__.py +139 -0
  2. evalrx/agent_assets/__init__.py +2 -0
  3. evalrx/agent_assets/skills/README.md +28 -0
  4. evalrx/agent_assets/skills/eval-chart-style/SKILL.md +172 -0
  5. evalrx/agent_assets/skills/evalrx-report-ui/SKILL.md +116 -0
  6. evalrx/agent_assets/skills/nature-figure/LICENSE +201 -0
  7. evalrx/agent_assets/skills/nature-figure/README.md +412 -0
  8. evalrx/agent_assets/skills/nature-figure/SKILL.md +60 -0
  9. evalrx/agent_assets/skills/nature-figure/manifest.yaml +59 -0
  10. evalrx/agent_assets/skills/nature-figure/references/api.md +436 -0
  11. evalrx/agent_assets/skills/nature-figure/references/backend-selection.md +100 -0
  12. evalrx/agent_assets/skills/nature-figure/references/chart-types.md +281 -0
  13. evalrx/agent_assets/skills/nature-figure/references/common-patterns.md +350 -0
  14. evalrx/agent_assets/skills/nature-figure/references/demos.md +65 -0
  15. evalrx/agent_assets/skills/nature-figure/references/design-theory.md +439 -0
  16. evalrx/agent_assets/skills/nature-figure/references/figure-contract.md +93 -0
  17. evalrx/agent_assets/skills/nature-figure/references/figure-legend-conventions.md +71 -0
  18. evalrx/agent_assets/skills/nature-figure/references/nature-2026-observations.md +112 -0
  19. evalrx/agent_assets/skills/nature-figure/references/qa-contract.md +119 -0
  20. evalrx/agent_assets/skills/nature-figure/references/r-template-index.md +66 -0
  21. evalrx/agent_assets/skills/nature-figure/references/r-workflow.md +161 -0
  22. evalrx/agent_assets/skills/nature-figure/references/tutorials.md +251 -0
  23. evalrx/agent_assets/skills/nature-figure/static/core/contract.md +29 -0
  24. evalrx/agent_assets/skills/nature-figure/static/core/stance.md +37 -0
  25. evalrx/agent_assets/skills/nature-figure/static/fragments/backend/python.md +37 -0
  26. evalrx/agent_assets/skills/nature-figure/static/fragments/backend/r.md +44 -0
  27. evalrx/agent_assets/skills/outcome-driver-analysis/SKILL.md +213 -0
  28. evalrx/agent_assets/skills/outcome-driver-analysis/assets/analysis_report_template.md +53 -0
  29. evalrx/agent_assets/skills/outcome-driver-analysis/references/model_selection.md +72 -0
  30. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/explanatory_var_eda.R +130 -0
  31. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/explanatory_var_eda.py +150 -0
  32. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/fit_outcome_model.R +181 -0
  33. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/fit_outcome_model.py +186 -0
  34. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/univariate_eda.R +149 -0
  35. evalrx/agent_assets/skills/outcome-driver-analysis/scripts/univariate_eda.py +177 -0
  36. evalrx/agent_assets/skills.py +27 -0
  37. evalrx/agent_runtime/__init__.py +78 -0
  38. evalrx/agent_runtime/_docker_runner.py +89 -0
  39. evalrx/agent_runtime/cli_runtime.py +103 -0
  40. evalrx/agent_runtime/cli_transcript.py +138 -0
  41. evalrx/agent_runtime/cli_types.py +68 -0
  42. evalrx/agent_runtime/codegen/__init__.py +5 -0
  43. evalrx/agent_runtime/codegen/runner.py +94 -0
  44. evalrx/agent_runtime/experiment_harness.py +117 -0
  45. evalrx/agent_runtime/factory.py +102 -0
  46. evalrx/agent_runtime/json_shape.py +44 -0
  47. evalrx/agent_runtime/judges/__init__.py +28 -0
  48. evalrx/agent_runtime/judges/agy.py +179 -0
  49. evalrx/agent_runtime/judges/autodetect.py +135 -0
  50. evalrx/agent_runtime/judges/claude.py +159 -0
  51. evalrx/agent_runtime/judges/codex.py +120 -0
  52. evalrx/agent_runtime/providers/__init__.py +21 -0
  53. evalrx/agent_runtime/providers/antigravity.py +31 -0
  54. evalrx/agent_runtime/providers/base.py +145 -0
  55. evalrx/agent_runtime/providers/claude_code.py +49 -0
  56. evalrx/agent_runtime/providers/codex.py +37 -0
  57. evalrx/agent_runtime/providers/gemini_cli.py +26 -0
  58. evalrx/agent_runtime/providers/kimi_cli.py +27 -0
  59. evalrx/agent_runtime/providers/opencode.py +27 -0
  60. evalrx/agent_runtime/providers/registry.py +58 -0
  61. evalrx/agent_runtime/sandbox.py +517 -0
  62. evalrx/agent_runtime/skill_audit.py +143 -0
  63. evalrx/agent_runtime/skills/__init__.py +19 -0
  64. evalrx/agent_runtime/skills/installer.py +68 -0
  65. evalrx/agent_runtime/skills/prompt_policy.py +86 -0
  66. evalrx/agent_runtime/skills/resolver.py +19 -0
  67. evalrx/analysis/__init__.py +132 -0
  68. evalrx/analysis/adjudicate.py +154 -0
  69. evalrx/analysis/analysis_module.py +361 -0
  70. evalrx/analysis/api.py +171 -0
  71. evalrx/analysis/case_studio.py +651 -0
  72. evalrx/analysis/cli.py +114 -0
  73. evalrx/analysis/dashboard.py +350 -0
  74. evalrx/analysis/eval_case_matrix.py +118 -0
  75. evalrx/analysis/eval_viz_theme.py +833 -0
  76. evalrx/analysis/explore_run.py +333 -0
  77. evalrx/analysis/explorer.py +1276 -0
  78. evalrx/analysis/failure_modes.py +607 -0
  79. evalrx/analysis/fused_pipeline.py +489 -0
  80. evalrx/analysis/holdout.py +300 -0
  81. evalrx/analysis/hypothesis_agent.py +230 -0
  82. evalrx/analysis/narration.py +177 -0
  83. evalrx/analysis/operationalize.py +442 -0
  84. evalrx/analysis/plain_language.py +42 -0
  85. evalrx/analysis/planner.py +283 -0
  86. evalrx/analysis/probe_search.py +203 -0
  87. evalrx/analysis/profile.py +268 -0
  88. evalrx/analysis/prompts/__init__.py +0 -0
  89. evalrx/analysis/prompts/explorer.py +417 -0
  90. evalrx/analysis/prompts/failure_modes.py +33 -0
  91. evalrx/analysis/prompts/holdout.py +27 -0
  92. evalrx/analysis/prompts/hypothesis_agent.py +78 -0
  93. evalrx/analysis/prompts/run_codebase.py +47 -0
  94. evalrx/analysis/prompts/stats_agent.py +72 -0
  95. evalrx/analysis/prompts/stats_tool_generator.py +43 -0
  96. evalrx/analysis/result_marker.py +47 -0
  97. evalrx/analysis/run_codebase.py +242 -0
  98. evalrx/analysis/run_view.py +205 -0
  99. evalrx/analysis/stage_views.py +93 -0
  100. evalrx/analysis/stats_agent.py +944 -0
  101. evalrx/analysis/stats_tool_agent.py +261 -0
  102. evalrx/analysis/stats_tool_generator.py +415 -0
  103. evalrx/analysis/stats_tools.py +1153 -0
  104. evalrx/analysis/trajectory_records.py +193 -0
  105. evalrx/analysis/workbench.py +431 -0
  106. evalrx/analyzers/__init__.py +42 -0
  107. evalrx/analyzers/agent/__init__.py +25 -0
  108. evalrx/analyzers/agent/counterfactual.py +84 -0
  109. evalrx/analyzers/agent/first_error_judge.py +96 -0
  110. evalrx/analyzers/agent/ignored_obs.py +81 -0
  111. evalrx/analyzers/agent/loop_detect.py +79 -0
  112. evalrx/analyzers/agent/reliability.py +165 -0
  113. evalrx/analyzers/agent/tool_shap.py +225 -0
  114. evalrx/analyzers/agent/trajectory_rubric.py +168 -0
  115. evalrx/analyzers/attention/__init__.py +19 -0
  116. evalrx/analyzers/attention/relative_attn.py +610 -0
  117. evalrx/analyzers/attention/rollout.py +73 -0
  118. evalrx/analyzers/attention/sink.py +56 -0
  119. evalrx/analyzers/attention/summary.py +190 -0
  120. evalrx/analyzers/attribution/__init__.py +6 -0
  121. evalrx/analyzers/attribution/generic_attn.py +31 -0
  122. evalrx/analyzers/attribution/gradcam.py +30 -0
  123. evalrx/analyzers/base.py +12 -0
  124. evalrx/analyzers/geometry/__init__.py +6 -0
  125. evalrx/analyzers/geometry/cka.py +70 -0
  126. evalrx/analyzers/geometry/linear_probe.py +157 -0
  127. evalrx/analyzers/hallucination/__init__.py +9 -0
  128. evalrx/analyzers/hallucination/chair.py +78 -0
  129. evalrx/analyzers/hallucination/opera.py +29 -0
  130. evalrx/analyzers/hallucination/pope.py +119 -0
  131. evalrx/analyzers/hallucination/selfcheck.py +155 -0
  132. evalrx/analyzers/hallucination/vcd.py +29 -0
  133. evalrx/analyzers/lens/__init__.py +7 -0
  134. evalrx/analyzers/lens/layer_contrast.py +133 -0
  135. evalrx/analyzers/lens/logit_lens.py +138 -0
  136. evalrx/analyzers/lens/tuned_lens.py +30 -0
  137. evalrx/analyzers/patching/__init__.py +5 -0
  138. evalrx/analyzers/patching/causal_trace.py +30 -0
  139. evalrx/analyzers/perturbation/__init__.py +23 -0
  140. evalrx/analyzers/perturbation/_shapley.py +54 -0
  141. evalrx/analyzers/perturbation/context_shap.py +174 -0
  142. evalrx/analyzers/perturbation/cot_faithfulness.py +239 -0
  143. evalrx/analyzers/perturbation/format_sensitivity.py +237 -0
  144. evalrx/analyzers/perturbation/mm_shap.py +146 -0
  145. evalrx/analyzers/perturbation/modality_ablation.py +196 -0
  146. evalrx/analyzers/perturbation/perturbation_battery.py +274 -0
  147. evalrx/analyzers/perturbation/prompt_contrast.py +265 -0
  148. evalrx/analyzers/perturbation/rise.py +94 -0
  149. evalrx/analyzers/perturbation/vl_shap.py +102 -0
  150. evalrx/analyzers/reasoning/__init__.py +33 -0
  151. evalrx/analyzers/reasoning/_text.py +328 -0
  152. evalrx/analyzers/reasoning/answer_extraction_audit.py +327 -0
  153. evalrx/analyzers/reasoning/arith_audit.py +226 -0
  154. evalrx/analyzers/reasoning/contamination.py +214 -0
  155. evalrx/analyzers/reasoning/knowledge_split.py +253 -0
  156. evalrx/analyzers/reasoning/self_repair.py +246 -0
  157. evalrx/analyzers/reasoning/step_rollout_value.py +216 -0
  158. evalrx/analyzers/reasoning/termination_audit.py +258 -0
  159. evalrx/analyzers/uncertainty/__init__.py +18 -0
  160. evalrx/analyzers/uncertainty/calibration.py +174 -0
  161. evalrx/analyzers/uncertainty/coverage_gap.py +199 -0
  162. evalrx/analyzers/uncertainty/entropy.py +90 -0
  163. evalrx/analyzers/uncertainty/logprob_entropy.py +69 -0
  164. evalrx/analyzers/uncertainty/self_consistency.py +204 -0
  165. evalrx/analyzers/uncertainty/verbalized_conf.py +64 -0
  166. evalrx/cli.py +411 -0
  167. evalrx/config.py +77 -0
  168. evalrx/contract/__init__.py +179 -0
  169. evalrx/contract/common.py +452 -0
  170. evalrx/contract/emit.py +948 -0
  171. evalrx/contract/export.py +237 -0
  172. evalrx/contract/m1.py +325 -0
  173. evalrx/contract/m2.py +317 -0
  174. evalrx/contract/m3.py +165 -0
  175. evalrx/contract/m4.py +130 -0
  176. evalrx/contract/m5.py +292 -0
  177. evalrx/contract/methodology.py +76 -0
  178. evalrx/contract/pre_m1.py +58 -0
  179. evalrx/contract/typescript.py +140 -0
  180. evalrx/core/__init__.py +85 -0
  181. evalrx/core/analyzer.py +174 -0
  182. evalrx/core/capability.py +54 -0
  183. evalrx/core/case.py +443 -0
  184. evalrx/core/experiment.py +106 -0
  185. evalrx/core/model.py +198 -0
  186. evalrx/core/pipeline.py +42 -0
  187. evalrx/core/registry.py +142 -0
  188. evalrx/core/result.py +64 -0
  189. evalrx/core/spec.py +173 -0
  190. evalrx/core/tokentype.py +165 -0
  191. evalrx/core/tool.py +92 -0
  192. evalrx/datasets/__init__.py +41 -0
  193. evalrx/datasets/base.py +68 -0
  194. evalrx/datasets/gui_os.py +52 -0
  195. evalrx/datasets/llm_qa.py +57 -0
  196. evalrx/datasets/pure_qa.py +12 -0
  197. evalrx/datasets/vlm_qa.py +695 -0
  198. evalrx/datasets/web_search_qa.py +52 -0
  199. evalrx/eval_agent/__init__.py +341 -0
  200. evalrx/eval_agent/_tools.py +81 -0
  201. evalrx/eval_agent/ab_runner.py +50 -0
  202. evalrx/eval_agent/agentic/__init__.py +43 -0
  203. evalrx/eval_agent/agentic/actions.py +216 -0
  204. evalrx/eval_agent/agentic/board.py +107 -0
  205. evalrx/eval_agent/agentic/loop.py +190 -0
  206. evalrx/eval_agent/agentic/tools.py +538 -0
  207. evalrx/eval_agent/checkpoint.py +57 -0
  208. evalrx/eval_agent/cli_agent.py +59 -0
  209. evalrx/eval_agent/cli_skills.py +5 -0
  210. evalrx/eval_agent/evolution.py +396 -0
  211. evalrx/eval_agent/git_manager.py +215 -0
  212. evalrx/eval_agent/hypothesis.py +172 -0
  213. evalrx/eval_agent/label_quarantine.py +209 -0
  214. evalrx/eval_agent/legacy.py +530 -0
  215. evalrx/eval_agent/log_schema.py +497 -0
  216. evalrx/eval_agent/loop.py +2159 -0
  217. evalrx/eval_agent/loop_reports.py +116 -0
  218. evalrx/eval_agent/model_instrumentation.py +282 -0
  219. evalrx/eval_agent/narration.py +193 -0
  220. evalrx/eval_agent/nl_runner.py +460 -0
  221. evalrx/eval_agent/orchestrator.py +61 -0
  222. evalrx/eval_agent/preregister.py +93 -0
  223. evalrx/eval_agent/prompts/__init__.py +1 -0
  224. evalrx/eval_agent/prompts/agentic.py +46 -0
  225. evalrx/eval_agent/prompts/case_discovery.py +25 -0
  226. evalrx/eval_agent/prompts/diagnosis.py +125 -0
  227. evalrx/eval_agent/prompts/experiment_writer.py +265 -0
  228. evalrx/eval_agent/prompts/explore_step.py +37 -0
  229. evalrx/eval_agent/prompts/fix_agent.py +257 -0
  230. evalrx/eval_agent/prompts/hypothesis_tester.py +15 -0
  231. evalrx/eval_agent/prompts/nl_runner.py +38 -0
  232. evalrx/eval_agent/prompts/probe_agent.py +25 -0
  233. evalrx/eval_agent/prompts/probe_candidate_generator.py +14 -0
  234. evalrx/eval_agent/prompts/probe_generator.py +35 -0
  235. evalrx/eval_agent/prompts/whitebox_probe_generator.py +38 -0
  236. evalrx/eval_agent/report.py +58 -0
  237. evalrx/eval_agent/run_context.py +354 -0
  238. evalrx/eval_agent/run_log.schema.json +1215 -0
  239. evalrx/eval_agent/run_logger_v2.py +1764 -0
  240. evalrx/eval_agent/run_metadata.py +208 -0
  241. evalrx/eval_agent/stages/__init__.py +56 -0
  242. evalrx/eval_agent/stages/case_discovery.py +293 -0
  243. evalrx/eval_agent/stages/diagnosis.py +1017 -0
  244. evalrx/eval_agent/stages/experiment_writer.py +1634 -0
  245. evalrx/eval_agent/stages/fix_agent.py +3916 -0
  246. evalrx/eval_agent/stages/fix_internals.py +499 -0
  247. evalrx/eval_agent/stages/fix_pipeline.py +725 -0
  248. evalrx/eval_agent/stages/fix_tiers.py +187 -0
  249. evalrx/eval_agent/stages/fix_tools.py +1034 -0
  250. evalrx/eval_agent/stages/hypothesis_tester.py +1014 -0
  251. evalrx/eval_agent/stages/probe.py +439 -0
  252. evalrx/eval_agent/stages/probe_agent.py +1079 -0
  253. evalrx/eval_agent/stages/probe_candidate_generator.py +128 -0
  254. evalrx/eval_agent/stages/probe_generator.py +326 -0
  255. evalrx/eval_agent/stages/probe_search_agent.py +106 -0
  256. evalrx/eval_agent/stages/protocol.py +112 -0
  257. evalrx/eval_agent/stages/repair_catalog.py +273 -0
  258. evalrx/eval_agent/stages/surgery.py +524 -0
  259. evalrx/eval_agent/stages/whitebox_probe_generator.py +351 -0
  260. evalrx/eval_agent/store.py +231 -0
  261. evalrx/logging_utils.py +112 -0
  262. evalrx/models/__init__.py +161 -0
  263. evalrx/models/_discover.py +101 -0
  264. evalrx/models/agent.py +380 -0
  265. evalrx/models/backends/__init__.py +58 -0
  266. evalrx/models/backends/api.py +169 -0
  267. evalrx/models/backends/base.py +57 -0
  268. evalrx/models/backends/gemini_compat.py +579 -0
  269. evalrx/models/backends/hf_local.py +2074 -0
  270. evalrx/models/backends/openai_compat.py +301 -0
  271. evalrx/models/backends/vllm_offline.py +116 -0
  272. evalrx/models/base.py +24 -0
  273. evalrx/models/blackbox/__init__.py +4 -0
  274. evalrx/models/blackbox/agent.py +31 -0
  275. evalrx/models/blackbox/base.py +29 -0
  276. evalrx/models/blackbox/gemini.py +279 -0
  277. evalrx/models/blackbox/llm_api.py +17 -0
  278. evalrx/models/blackbox/vlm_api.py +17 -0
  279. evalrx/models/compose.py +66 -0
  280. evalrx/models/inference.py +88 -0
  281. evalrx/models/paper_methods/__init__.py +8 -0
  282. evalrx/models/paper_methods/aad.py +53 -0
  283. evalrx/models/paper_methods/ifcd.py +204 -0
  284. evalrx/models/paper_methods/pai.py +164 -0
  285. evalrx/models/paper_methods/tcd.py +202 -0
  286. evalrx/models/paper_methods/vcd.py +45 -0
  287. evalrx/models/paper_methods/vicrop.py +137 -0
  288. evalrx/models/toolcodec.py +143 -0
  289. evalrx/models/tools/__init__.py +20 -0
  290. evalrx/models/tools/perception.py +300 -0
  291. evalrx/models/tools/visual.py +174 -0
  292. evalrx/models/whitebox/__init__.py +26 -0
  293. evalrx/models/whitebox/agent.py +31 -0
  294. evalrx/models/whitebox/base.py +24 -0
  295. evalrx/models/whitebox/qwen.py +61 -0
  296. evalrx/models/whitebox/qwen2_5_omni.py +29 -0
  297. evalrx/models/whitebox/qwen2_audio.py +25 -0
  298. evalrx/models/whitebox/qwen_omni.py +53 -0
  299. evalrx/models/whitebox/qwen_vl.py +62 -0
  300. evalrx/observability/__init__.py +21 -0
  301. evalrx/observability/envelope.py +122 -0
  302. evalrx/observability/outbox.py +111 -0
  303. evalrx/observability/tracer.py +882 -0
  304. evalrx/reporting/__init__.py +28 -0
  305. evalrx/reporting/case_study.py +947 -0
  306. evalrx/reporting/compiler.py +587 -0
  307. evalrx/reporting/dynamic.py +1882 -0
  308. evalrx/reporting/html_report.py +2225 -0
  309. evalrx/reporting/langfuse_exporter.py +38 -0
  310. evalrx/reporting/langfuse_source.py +155 -0
  311. evalrx/reporting/model.py +151 -0
  312. evalrx/reporting/run_events.py +184 -0
  313. evalrx/reporting/server.py +557 -0
  314. evalrx/reporting/stages.py +58 -0
  315. evalrx/reporting/static_export.py +142 -0
  316. evalrx/reporting/web_dist/index.html +146 -0
  317. evalrx/specs.py +727 -0
  318. evalrx/stats/__init__.py +47 -0
  319. evalrx/stats/api.py +192 -0
  320. evalrx/stats/bootstrap.py +86 -0
  321. evalrx/stats/ebh.py +27 -0
  322. evalrx/stats/evalue.py +98 -0
  323. evalrx/stats/friedman.py +138 -0
  324. evalrx/stats/mcnemar.py +40 -0
  325. evalrx/stats/multiplicity.py +159 -0
  326. evalrx/stats/subset_sampling.py +55 -0
  327. evalrx/term_links.py +43 -0
  328. evalrx/viz/__init__.py +7 -0
  329. evalrx/viz/labels.py +77 -0
  330. evalrx/viz/prompts.py +39 -0
  331. evalrx/viz/renderer.py +590 -0
  332. evalrx/viz/schema.py +36 -0
  333. evalrx/viz/style.py +134 -0
  334. evalrx-0.1.2.dist-info/METADATA +532 -0
  335. evalrx-0.1.2.dist-info/RECORD +339 -0
  336. evalrx-0.1.2.dist-info/WHEEL +5 -0
  337. evalrx-0.1.2.dist-info/entry_points.txt +3 -0
  338. evalrx-0.1.2.dist-info/licenses/LICENSE +121 -0
  339. evalrx-0.1.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,412 @@
1
+ # `nature-figure` 技能
2
+
3
+ > **EvalRX adaptation notice (Apache-2.0 modification):** the canonical
4
+ > palette constants in `references/api.md` and `references/design-theory.md`
5
+ > (`PALETTE` / `DEFAULT_COLORS`) have been re-valued to the CVD-validated
6
+ > EvalRX dataviz palette, so agent-drawn figures, host plotly charts, and
7
+ > host spec-rendered PNGs share one palette (key names and family semantics
8
+ > unchanged; typography/layout/export guidance untouched). Hex values inside
9
+ > tutorial/example snippets elsewhere in this skill are illustrative and were
10
+ > not rewritten — the constants above and the `eval-chart-style` skill's
11
+ > palette are authoritative. In EvalRX sandboxes, chart-type and palette
12
+ > decisions belong to `eval-chart-style`; this skill supplies publication
13
+ > polish.
14
+
15
+ `nature-figure` 用于生成可投稿级科研图,面向 Nature 级期刊和高影响力学术场景,同时支持 Python 与 R 两条绘图路径。
16
+
17
+ 该技能从“图件契约”开始,而不是直接套模板。开始绘图前,必须明确核心结论、证据层级、图件原型、后端选择、期刊与导出约束、统计说明和 source-data 可追溯性。只有在科学逻辑明确后,才使用绘图模板。
18
+
19
+ Python 路径主要使用 `matplotlib`、`seaborn`、`subplot_mosaic` 和 `statsmodels`,适合精细低层布局控制。R 路径使用 `ggplot2`、`patchwork`、`ComplexHeatmap`、`ggrepel`、`svglite`、`cairo_pdf` 和 `ragg`。如果使用私有模板集合,不得在面向用户的输出中暴露私有路径、文件名或来源信息。
20
+
21
+ 该技能参考了 [figures4papers](https://github.com/ChenLiu-1996/figures4papers) 中来自 *Nature Machine Intelligence* 和顶级机器学习/生物信息学论文的生产脚本。原始 demo 脚本和预览图也打包在 `assets/figures4papers/` 中,供模式级改写使用。
22
+
23
+ ---
24
+
25
+ ## 示例图库
26
+
27
+ 下面的图像是按本技能规则生成的模拟数据 mockup:优先导出可编辑 SVG、使用克制的语义配色、小写 panel label,并采用非对称多面板信息结构。README 中展示的是 PNG 预览;正式使用时仍应从绘图脚本导出 SVG/PDF。
28
+
29
+ | 图件 | 预览 | 展示能力 |
30
+ |--------|---------|-----------------------------|
31
+ | 材料设计与物理验证 | <a href="assets/gallery/fig1-material-mechanism-rich.png"><img src="assets/gallery/fig1-material-mechanism-rich.png" width="260" alt="Material design and physical validation"></a> | 机制示意主导的复合图、SEM-like 图像面板、流变、释放动力学、滞留图、相关性与终点定量 |
32
+ | 空间滞留与摄取 | <a href="assets/gallery/fig2-spatial-imaging-rich.png"><img src="assets/gallery/fig2-spatial-imaging-rich.png" width="260" alt="Spatial retention and uptake"></a> | 深色显微图版、通道行、局部放大、深度剖面、摄取直方图、3D 穿透热图和图像衍生相关性 |
33
+ | 体内疗效与耐受性 | <a href="assets/gallery/fig3-in-vivo-efficacy-rich.png"><img src="assets/gallery/fig3-in-vivo-efficacy-rich.png" width="260" alt="In vivo efficacy and tolerability"></a> | 实验时间线、肿瘤纵向曲线、个体生长轨迹、waterfall response、forest plot、组织学、免疫组成和毒性面板 |
34
+ | 单细胞系统图 | <a href="assets/gallery/fig4-single-cell-systems-rich.png"><img src="assets/gallery/fig4-single-cell-systems-rich.png" width="260" alt="Single-cell systems figure"></a> | UMAP-style embedding、组成、marker heatmap、pseudotime、volcano plot、enrichment、ligand-receptor bubble matrix 和空间邻域关系 |
35
+ | 扰动验证 | <a href="assets/gallery/fig5-validation-perturbation-rich.png"><img src="assets/gallery/fig5-validation-perturbation-rich.png" width="260" alt="Perturbation validation"></a> | 机制扰动时间线、复发终点、polar summary、剂量反应、synergy matrix、生物分布、细胞因子、flow-like scatter 和安全评分 |
36
+
37
+ **图库文件策略**:`assets/gallery/` 中只保留轻量 PNG 预览。除非教程确实需要,不提交大型生成 SVG/PDF,因为真实用户应从源数据和脚本重新生成可编辑输出。
38
+
39
+ ---
40
+
41
+ ## 图表类型图谱
42
+
43
+ 下面的图库按 chart family 分类。每张预览都是紧凑的 4 x 4 小面板 atlas,用来展示可组合进 Nature 风格结果图的视觉语法范围。
44
+
45
+ | 类型 | 预览 | 常见用途 |
46
+ |------|---------|------------|
47
+ | 柱状图 | <a href="assets/chart-atlas/atlas-01-bar-charts.png"><img src="assets/chart-atlas/atlas-01-bar-charts.png" width="240" alt="Bar chart atlas"></a> | 组间比较、有符号差值、组内分组设计、堆叠组成 |
48
+ | 折线与纵向趋势 | <a href="assets/chart-atlas/atlas-02-line-trends.png"><img src="assets/chart-atlas/atlas-02-line-trends.png" width="240" alt="Line chart atlas"></a> | 时间过程、不确定性带、干预标记、个体轨迹 |
49
+ | 热图 | <a href="assets/chart-atlas/atlas-03-heatmaps.png"><img src="assets/chart-atlas/atlas-03-heatmaps.png" width="240" alt="Heatmap atlas"></a> | Z-score 矩阵、连续丰度图、带注释表格、聚类块 |
50
+ | 散点与气泡图 | <a href="assets/chart-atlas/atlas-04-scatter-bubble.png"><img src="assets/chart-atlas/atlas-04-scatter-bubble.png" width="240" alt="Scatter and bubble atlas"></a> | 相关性、簇、volcano-style 检验、象限总结、第三变量编码 |
51
+ | 雷达与极坐标图 | <a href="assets/chart-atlas/atlas-05-radar-polar.png"><img src="assets/chart-atlas/atlas-05-radar-polar.png" width="240" alt="Radar and polar atlas"></a> | 多轴 benchmarking、圆形摘要、polar histogram、方向密度 |
52
+ | 分布图 | <a href="assets/chart-atlas/atlas-06-distributions.png"><img src="assets/chart-atlas/atlas-06-distributions.png" width="240" alt="Distribution plot atlas"></a> | 直方图、小提琴图、箱线图、ridgeline 和样本级分布 |
53
+ | Forest 与区间图 | <a href="assets/chart-atlas/atlas-07-forest-interval.png"><img src="assets/chart-atlas/atlas-07-forest-interval.png" width="240" alt="Forest and interval atlas"></a> | 效应量、置信区间、点范围、配对斜率比较 |
54
+ | 面积与堆叠趋势 | <a href="assets/chart-atlas/atlas-08-area-stacked.png"><img src="assets/chart-atlas/atlas-08-area-stacked.png" width="240" alt="Area and stacked trend atlas"></a> | 填充轨迹、份额堆叠、累计曲线、stream-like 构图 |
55
+ | 图像板 | <a href="assets/chart-atlas/atlas-09-image-plates.png"><img src="assets/chart-atlas/atlas-09-image-plates.png" width="240" alt="Image plate atlas"></a> | 显微通道、叠加图、裁剪、比例尺和暗色面板 |
56
+ | 网络与矩阵图 | <a href="assets/chart-atlas/atlas-10-network-matrix.png"><img src="assets/chart-atlas/atlas-10-network-matrix.png" width="240" alt="Network and matrix atlas"></a> | 气泡矩阵、邻接图、node-link 图和二分互作面板 |
57
+
58
+ ---
59
+
60
+ ## 文件结构
61
+
62
+ 该技能采用 router/static-dynamic 结构:短 `SKILL.md` 路由配合 `manifest.yaml`,加载常驻 core、用户选择的后端片段,以及按需 references。
63
+
64
+ ```text
65
+ nature-figure/
66
+ ├── SKILL.md # 短路由:后端 gate,加载 fragments
67
+ ├── manifest.yaml # always_load core + backend axis + 按需 references
68
+ ├── README.md # 本文件
69
+ ├── static/
70
+ │ ├── core/ # 始终加载
71
+ │ │ ├── contract.md # 图件契约、后端 gate、互斥规则、运行时缺失处理
72
+ │ │ └── stance.md # 配色策略、默认立场、隐私、何时加载
73
+ │ └── fragments/
74
+ │ └── backend/ # 在 Python-or-R gate 解决后加载
75
+ │ ├── python.md # Python-only 规则与 matplotlib quick-start
76
+ │ └── r.md # R-only 规则与 ggplot2 quick-start
77
+ ├── assets/
78
+ │ ├── gallery/ # 结果图预览 PNG
79
+ │ ├── chart-atlas/ # 图表类型预览 PNG
80
+ │ └── figures4papers/ # 原始 demo 脚本和预览资产
81
+ └── references/ # 按需打开
82
+ ├── figure-contract.md # 核心结论、证据层级、panel map
83
+ ├── backend-selection.md # Python vs R 选择规则
84
+ ├── r-workflow.md # R scaffold、patchwork、ComplexHeatmap、导出
85
+ ├── r-template-index.md # 本地 R template atlas
86
+ ├── qa-contract.md # 投稿/返修 QA 清单
87
+ ├── api.md # PALETTE 常量、helper 函数签名
88
+ ├── design-theory.md # 字体、色彩理论、布局、导出策略
89
+ ├── common-patterns.md # 可复用代码模式
90
+ ├── tutorials.md # 端到端教程
91
+ ├── chart-types.md # radar、3D sphere、scatter、fill_between、log-scale
92
+ └── demos.md # figures4papers demo map 与路由指南
93
+ ```
94
+
95
+ ---
96
+
97
+ ## 后端与图件契约规则
98
+
99
+ 除非用户已经指定后端,否则先询问用户选择 **Python 或 R**。如果用户需要推荐,参考 `references/backend-selection.md`。
100
+
101
+ 后端一旦选定,绘图、预览、导出和视觉 QA 都必须只使用该后端。如果所选运行时或包缺失,应停止并报告 blocker;不要用另一种语言临时替代。该规则双向适用:不能用 Python 替代 R,也不能用 R 替代 Python。
102
+
103
+ 绘图前必须写明或推断核心结论、图件原型、panel map、证据层级、目标输出、统计/source-data 需求和导出包。图件首先服务科学逻辑,美观和模板匹配是次级目标。
104
+
105
+ 面向用户的输出不得暴露私有本地路径、私有文件名、内部参考文档、模板编号或私有材料来源,除非用户明确要求审计轨迹。
106
+
107
+ ---
108
+
109
+ ## Python 强制规则
110
+
111
+ ### 1. 三个必需 rcParams:保留 SVG 可编辑文本
112
+
113
+ ```python
114
+ plt.rcParams['font.family'] = 'sans-serif'
115
+ plt.rcParams['font.sans-serif'] = ['Arial', 'DejaVu Sans', 'Liberation Sans']
116
+ plt.rcParams['svg.fonttype'] = 'none'
117
+ ```
118
+
119
+ `svg.fonttype = 'none'` 可以避免 matplotlib 默认把每个字形转为 bezier 曲线。这样导出的 SVG 中,文字仍是 `<text>` 节点,可选择、可搜索,也方便在 Illustrator 或 Inkscape 中重新对齐。
120
+
121
+ 字体栈中包含 `Arial`、`DejaVu Sans` 和 `Liberation Sans`:`Arial` 是 macOS/Windows 常见字体,`DejaVu Sans` 随 matplotlib 提供,`Liberation Sans` 在 RHEL/Ubuntu 上与 Arial 度量兼容。这个级联能提高跨平台字距一致性。
122
+
123
+ ### 2. 主输出格式是 SVG
124
+
125
+ ```python
126
+ fig.savefig('figure.svg', bbox_inches='tight') # 主输出:可编辑文本
127
+ fig.savefig('figure.png', dpi=300, bbox_inches='tight') # 可选栅格预览
128
+ ```
129
+
130
+ 当图要进入论文或需要后期文字微调的 slide deck 时,不要只导出 PNG。
131
+
132
+ ### 3. 始终关闭 figure
133
+
134
+ ```python
135
+ plt.close(fig)
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 快速模板
141
+
142
+ ```python
143
+ import matplotlib
144
+ matplotlib.use('Agg') # headless / server rendering
145
+ import matplotlib.pyplot as plt
146
+ import matplotlib.gridspec as gridspec
147
+ import numpy as np
148
+
149
+ # 必需设置
150
+ plt.rcParams['font.family'] = 'sans-serif'
151
+ plt.rcParams['font.sans-serif'] = ['Arial', 'DejaVu Sans', 'Liberation Sans']
152
+ plt.rcParams['svg.fonttype'] = 'none'
153
+
154
+ # 基础样式
155
+ plt.rcParams.update({
156
+ 'font.size': 12,
157
+ 'axes.spines.right': False,
158
+ 'axes.spines.top': False,
159
+ 'axes.linewidth': 2.0,
160
+ 'legend.frameon': False,
161
+ 'xtick.major.width': 1.5,
162
+ 'ytick.major.width': 1.5,
163
+ })
164
+
165
+ # 图件
166
+ fig, ax = plt.subplots(figsize=(8, 5))
167
+ ax.spines['bottom'].set_linewidth(2)
168
+ ax.spines['left'].set_linewidth(2)
169
+
170
+ # ... 在这里写绘图代码 ...
171
+
172
+ fig.tight_layout(pad=2)
173
+ fig.savefig('output.svg', bbox_inches='tight')
174
+ fig.savefig('output.png', dpi=300, bbox_inches='tight')
175
+ plt.close(fig)
176
+ ```
177
+
178
+ ---
179
+
180
+ ## 配色方案
181
+
182
+ ```python
183
+ PALETTE = {
184
+ # 主方法 / 核心系列
185
+ 'blue_main': '#0F4D92',
186
+ 'blue_secondary': '#3775BA',
187
+
188
+ # 正向 / 提升色阶
189
+ 'green_1': '#DDF3DE',
190
+ 'green_2': '#AADCA9',
191
+ 'green_3': '#8BCF8B',
192
+
193
+ # 基线 / 对照
194
+ 'red_1': '#F6CFCB',
195
+ 'red_2': '#E9A6A1',
196
+ 'red_strong': '#B64342',
197
+
198
+ # 中性辅助
199
+ 'neutral_light': '#CFCECE',
200
+ 'neutral_mid': '#767676',
201
+ 'neutral_dark': '#4D4D4D',
202
+ 'neutral_black': '#272727',
203
+
204
+ # 强调色,谨慎使用
205
+ 'gold': '#FFD700',
206
+ 'teal': '#42949E',
207
+ 'violet': '#9A4D8E',
208
+ 'magenta': '#EA84DD',
209
+ }
210
+ ```
211
+
212
+ 语义映射约定:`blue_main` 表示本文方法或核心系列,`green_3` 表示正向变体,`red_strong` 表示基线,`neutral_light` 表示参考或背景。所有 panel 中必须保持一致。
213
+
214
+ 推荐在近期 Nature Machine Intelligence 风格的密集多面板图中使用统一低饱和配色:一个 coherent baseline family 加一个 coherent hero family,绿色/红色只用于差值标记或真正有方向性的语义。
215
+
216
+ ```python
217
+ PALETTE_NMI_PASTEL = {
218
+ # 基线 / 对照家族
219
+ 'baseline_dark': '#484878',
220
+ 'baseline_mid': '#7884B4',
221
+ 'baseline_soft': '#B4C0E4',
222
+
223
+ # 本文方法家族
224
+ 'ours_tiny': '#E4E4F0',
225
+ 'ours_base': '#E4CCD8',
226
+ 'ours_large': '#F0C0CC',
227
+
228
+ # 概览 / 概念面板背景块
229
+ 'bg_lilac': '#E0E0F0',
230
+ 'bg_aqua': '#E0F0F0',
231
+ 'bg_peach': '#F0E0D0',
232
+
233
+ # 中性辅助
234
+ 'neutral_light': '#D8D8D8',
235
+ 'neutral_mid': '#A8A8A8',
236
+ 'neutral_dark': '#606060',
237
+
238
+ # 仅用于方向性标注
239
+ 'delta_up': '#2E9E44',
240
+ 'delta_down': '#E53935',
241
+ }
242
+
243
+ DEFAULT_COLORS_NMI_PASTEL = [
244
+ PALETTE_NMI_PASTEL['baseline_dark'],
245
+ PALETTE_NMI_PASTEL['baseline_mid'],
246
+ PALETTE_NMI_PASTEL['baseline_soft'],
247
+ PALETTE_NMI_PASTEL['ours_tiny'],
248
+ PALETTE_NMI_PASTEL['ours_base'],
249
+ PALETTE_NMI_PASTEL['ours_large'],
250
+ ]
251
+ ```
252
+
253
+ 适用场景:
254
+
255
+ - 比较 `Tiny / Base / Large` 等相关模型家族。
256
+ - 构建 1 页 result atlas,需要多个 panel 视觉统一。
257
+ - 追求低饱和编辑风格,而不是最大化类别区分。
258
+
259
+ 实践规则:同一方法家族在所有 panel 中保持同一 hue family。不要因为某个 panel 需要对比,就把 panel `a` 中的蓝灰模型在 panel `d` 里改成绿色。
260
+
261
+ ---
262
+
263
+ ## 支持的图表类型
264
+
265
+ | 图表 | 文件 | 关键模式 |
266
+ |-------|------|-------------|
267
+ | 分组柱状图 | `tutorials.md` | `ax.bar()` 配合 `x + offset`,最后一个 panel 只放 legend |
268
+ | 堆叠柱状图 | `common-patterns.md` | 遍历 `col_order`,累计 `bottom` |
269
+ | 横向 ablation bar | `tutorials.md` | `ax.barh()`,用 alpha-gradient 编码完整性 |
270
+ | 趋势 / 折线 | `tutorials.md` + `api.md` | `make_trend()`,用 `fill_between` 表示不确定性 |
271
+ | 连续热图 | `api.md` | `make_heatmap()`、`YlOrRd`、按亮度决定 cell annotation 颜色 |
272
+ | 发散 / z-score 热图 | `design-theory.md §11` | `RdBu_r`,`vmin=-2.5, vmax=2.5` |
273
+ | 气泡散点图 | `design-theory.md §11` | x/y 表示两个维度,`s=` 表示第三变量 |
274
+ | 雷达 / 极坐标图 | `chart-types.md` | `projection='polar'`,自定义 spokes,逐轴归一化 |
275
+ | 3D sphere / illustration | `chart-types.md` | 用 numpy 网格 ray-cast 实现 Lambertian shading |
276
+ | Fill-between / 堆叠面积 | `chart-types.md` | 使用 hatch 保证灰度打印安全 |
277
+ | Log-scale bar | `chart-types.md` | `set_yscale('log')`,顶部留出标注空间 |
278
+ | 多面板 GridSpec | `chart-types.md` | `GridSpec(rows, cols)`,用 `gs[0, :]` 做全宽 panel |
279
+
280
+ ---
281
+
282
+ ## 多面板信息结构
283
+
284
+ 多面板图中的每个 panel 都必须回答一个**唯一**科学问题。遮住任意一个 panel 后,其他 panel 不应能完全替代它。
285
+
286
+ ### 推荐的三层递进复杂度
287
+
288
+ | 层级 | 问题 | 编码方式 |
289
+ |-------|----------|----------|
290
+ | Overview | “整体格局是什么?” | 堆叠柱、组成图 |
291
+ | Deviation | “每组的独特性是什么?” | Z-score 热图、发散色图 |
292
+ | Relationship | “变量之间如何共变?” | 气泡散点、相关性图 |
293
+
294
+ ### 常见冗余陷阱
295
+
296
+ | 陷阱 | 示例 | 修正 |
297
+ |------|---------|-----|
298
+ | 绝对值 + 绝对值 | 堆叠柱百分比 + 同一百分比热图 | 把热图换成 z-score deviation |
299
+ | 父集的子集 | tumor-only ranked bar 只是堆叠柱的一列 | 换成 tumor % vs immune % 散点 |
300
+ | 两个排序 | 两个相关指标的 ranked bar | 将其中一个换成气泡散点 |
301
+ | 图形不同但数据相同 | 饼图 + 堆叠柱 | 合并或换成关系图 |
302
+
303
+ ### Z-score deviation 热图
304
+
305
+ ```python
306
+ z = (heat - heat.mean(axis=0)) / heat.std(axis=0)
307
+ im = ax.imshow(z.values, cmap='RdBu_r', aspect='auto', vmin=-2.5, vmax=2.5)
308
+ cbar.set_label('Z-score vs pan-cohort mean')
309
+ ```
310
+
311
+ `RdBu_r` 中红色表示高于平均富集,蓝色表示低于平均。它与 panel a 中展示的绝对百分比形成正交信息。
312
+
313
+ ### 带象限标签的气泡散点
314
+
315
+ ```python
316
+ ax.scatter(x, y, s=size_var * scale, c=colors, edgecolors='white', linewidth=0.8, alpha=0.9)
317
+ ax.axvline(np.median(x), lw=1.2, ls='--', color='#767676', alpha=0.6)
318
+ ax.axhline(np.median(y), lw=1.2, ls='--', color='#767676', alpha=0.6)
319
+ ```
320
+
321
+ 象限标签放在角落,使用小号灰色斜体文字,例如 `fontsize=7.5, color='#888888', style='italic'`。
322
+
323
+ ---
324
+
325
+ ## 布局规则
326
+
327
+ ### Figure 尺寸
328
+
329
+ | 类型 | `figsize` |
330
+ |------|-----------|
331
+ | 多指标柱状图(3-4 个指标 + legend panel) | `(28-45, 6-12)` |
332
+ | 大型多面板图(3 panels,2-row GridSpec) | `(22, 17)` |
333
+ | 紧凑单柱状图 | `(9-16, 5-8)` |
334
+ | 趋势 / 折线多面板 | `(14, 4)` 或 `(9, 8)` |
335
+ | 单热图 | `(8-20, 5-9)` |
336
+ | 雷达极坐标 | `(12, 10)` |
337
+
338
+ 规则:比较型柱状面板的宽度通常约为高度的 3-4 倍。
339
+
340
+ ### Panel labels
341
+
342
+ ```python
343
+ ax.text(-0.05, 1.06, 'a', transform=ax.transAxes,
344
+ fontsize=22, fontweight='bold', va='top', ha='right')
345
+ ```
346
+
347
+ 每个 subplot 左上角使用小写粗体 `a`、`b`、`c`,通过 `transAxes` 放置。
348
+
349
+ ### Legend
350
+
351
+ - 多轴图件中,legend 应有独立 axis,例如 `ax.set_axis_off()`。
352
+ - 始终使用 `frameon=False`。
353
+ - 如果 legend 较大,放在 panel 下方:`bbox_to_anchor=(0.5, -0.24), loc='upper center'`。
354
+
355
+ ---
356
+
357
+ ## 字号层级
358
+
359
+ | 场景 | `font.size` |
360
+ |---------|-------------|
361
+ | 基础紧凑子图 | 12-16 |
362
+ | 大型柱状 panel(figsize > 28 in) | 24 |
363
+ | 大 panel 坐标轴标题 | 32-54,可逐标签覆盖 |
364
+ | 柱内 / cell 内注释 | 6.5-12 |
365
+ | Panel letter label | 20-22 |
366
+ | Legend | 8-14 |
367
+
368
+ ---
369
+
370
+ ## 坐标轴与边框规则
371
+
372
+ ```python
373
+ plt.rcParams['axes.spines.right'] = False
374
+ plt.rcParams['axes.spines.top'] = False
375
+ plt.rcParams['legend.frameon'] = False
376
+
377
+ ax.spines['bottom'].set_linewidth(2)
378
+ ax.spines['left'].set_linewidth(2)
379
+ ```
380
+
381
+ 默认不使用 gridline。用稀疏 `set_yticks` 引导阅读。Y 轴范围要贴近数据,不要在所有值都落在 `80-95` 时使用 `0-100`。
382
+
383
+ ---
384
+
385
+ ## Cell / bar 内文字对比度
386
+
387
+ ```python
388
+ def luminance_text_color(hex_color):
389
+ c = hex_color.lstrip('#')
390
+ r, g, b = int(c[0:2],16)/255, int(c[2:4],16)/255, int(c[4:6],16)/255
391
+ return 'white' if 0.299*r + 0.587*g + 0.114*b < 0.5 else '#333333'
392
+ ```
393
+
394
+ ---
395
+
396
+ ## 复现检查清单
397
+
398
+ - [ ] 核心结论和 panel map 在美化前已经明确。
399
+ - [ ] 后端已明确为 Python 或 R。
400
+ - [ ] **前 3 个设置**包含 `font.family`、`font.sans-serif` 三字体栈、`svg.fonttype = 'none'`。
401
+ - [ ] 主输出为 **SVG**,并使用 `bbox_inches='tight'`。
402
+ - [ ] 右侧和顶部 spines 关闭,`legend.frameon = False`。
403
+ - [ ] 字号符合最终用途:密集期刊图通常 5-7 pt,只有 slide-sized panel 才使用更大字号。
404
+ - [ ] 颜色来自同一个 coherent palette system:语义 `PALETTE` 或统一 `PALETTE_NMI_PASTEL`。
405
+ - [ ] 相关模型大小或变体共享同一 hue family,不给同胞系列分配不相关的高饱和颜色。
406
+ - [ ] 绿色 / 红色只用于提升、下降、阈值或真正有方向性的语义。
407
+ - [ ] Y 轴范围贴近数据范围。
408
+ - [ ] 多面板图中每个 panel 回答**不同**问题,已通过反冗余检查。
409
+ - [ ] Panel labels 使用粗体小写 `a`、`b`、`c`,字号适合最终输出。
410
+ - [ ] 面向手稿时,已记录统计、`n`、source data 和图像完整性说明。
411
+ - [ ] 保存前调用 `tight_layout(pad=2)`。
412
+ - [ ] 保存后调用 `plt.close(fig)`。
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: nature-figure
3
+ description: >-
4
+ Submission-grade Nature/high-impact journal figure workflow for Python or R. Use whenever the user asks to create, revise, audit, or polish manuscript figures, multi-panel scientific plots, figures4papers-style matplotlib plots, or journal-ready SVG/PDF/TIFF outputs, especially for Nature-family or other high-impact journals. Before plotting, define the figure's conclusion, evidence logic, export needs, and review risks. If the user has not chosen Python or R, ask "Python or R?" and stop. Use only the selected backend for figure generation, previewing, exporting, and QA. Supports matplotlib/seaborn and ggplot2/patchwork/ComplexHeatmap. Not for dashboards or Illustrator/Figma-first infographics. Also trigger on general academic-writing figure needs even without the word "Nature", such as making figures/plots for a paper, scientific/academic plotting, data visualization for a manuscript, and Chinese phrasings like 论文配图、学术写作配图、科研绘图、科研作图、画图、作图、出图、论文图表、可视化.
5
+ version: 2.0.0
6
+ author: Community contribution, refactored into static/dynamic layers
7
+ ---
8
+
9
+ # Nature Figure Making — Router
10
+
11
+ This skill is split into two layers:
12
+
13
+ - A **static layer** under `static/` that holds versioned, reusable content fragments (the figure contract and default stance, plus a per-backend quick-start for Python and R).
14
+ - A **dynamic layer** (this file plus `manifest.yaml`) that detects the plotting backend and loads only the fragment needed for the current job. The large design, API, pattern, and QA material lives in on-demand references.
15
+
16
+ Do not try to apply the figure logic from memory or from this router. Always load fragments from disk as described below.
17
+
18
+ ## Routing protocol
19
+
20
+ Follow these five steps every time the skill is invoked.
21
+
22
+ ### 1. Load the manifest and the core layer
23
+
24
+ Read [manifest.yaml](manifest.yaml). It declares the `backend` axis, the allowed values, and the file paths each value maps to.
25
+
26
+ Also read every file listed under `always_load` (`static/core/contract.md` and `static/core/stance.md`). These hold the figure contract, the backend gate, the missing-runtime rule, the privacy rule, and the default operating stance that apply to every figure job.
27
+
28
+ ### 2. Resolve the backend — a blocking gate
29
+
30
+ Backend selection blocks everything else. Decide the `backend` value only from an explicit user choice or a clearly language-specific input file/workflow:
31
+
32
+ - `python` — matplotlib / seaborn.
33
+ - `r` — ggplot2 / patchwork / ComplexHeatmap.
34
+
35
+ If the user has **not** explicitly chosen, ask exactly one concise question — **Python or R?** — and stop. Do not default, guess, generate mock data, or write scripts before the answer. Only recommend a backend when the user explicitly asks you to choose; then use `references/backend-selection.md`, state the reason, and proceed. Once selected, the backend is **exclusive** for all drawing, previewing, exporting, and visual QA (see `core/contract.md`).
36
+
37
+ ### 3. Load the matching backend fragment
38
+
39
+ After the backend is resolved, Read the mapped fragment (`static/fragments/backend/python.md` or `static/fragments/backend/r.md`). It carries the backend-only execution rule and the publication quick-start (rcParams/theme and export helper). Do **not** load the other backend's fragment.
40
+
41
+ ### 4. Build the figure using the loaded material
42
+
43
+ Apply the loaded material in this order:
44
+
45
+ 1. Figure contract (`core/contract.md`) — write the core conclusion, map the evidence chain, classify the archetype, set the journal/export contract, before any code.
46
+ 2. Default stance (`core/stance.md`) — archetype-first composition, hero panel, restrained palette, statistics/integrity as part of the figure.
47
+ 3. Backend fragment — the exclusive Python or R quick-start and execution rule.
48
+
49
+ The chart serves the scientific logic; aesthetic polish is subordinate to making the core conclusion clear, defensible, and reviewable.
50
+
51
+ ### 5. Reach for references only when needed
52
+
53
+ The files under `references/` are deep references, not defaults. Open them on demand per the `references.on_demand` table in the manifest — for example `references/figure-contract.md` to build the contract, `references/api.md` for the Python palette and helpers, `references/r-workflow.md` for R, `references/design-theory.md` for color/typography/export rationale, `references/common-patterns.md` and `references/chart-types.md` for layout/chart recipes, `references/nature-2026-observations.md` for real Nature page archetypes, `references/qa-contract.md` before final delivery, and `references/tutorials.md` / `references/demos.md` for worked examples.
54
+
55
+ ## Why this split
56
+
57
+ - The static layer is versioned and reviewable. The backend gate is now explicit in the manifest rather than buried in prose.
58
+ - The dynamic layer keeps each invocation cheap: only the selected backend's quick-start enters context, and the 2,600+ lines of reference depth load only when a step needs them.
59
+ - The router itself is short on purpose. Update fragments and references, not this file, when adding scope.
60
+ - This structure mirrors `nature-writing`, `nature-polishing`, `nature-reader`, and `nature-paper2ppt`.
@@ -0,0 +1,59 @@
1
+ name: nature-figure
2
+ version: 2.0.0
3
+ description: >
4
+ Declarative manifest for the static/dynamic split. SKILL.md uses this to
5
+ decide which fragments to load for a given figure request. The main axis is
6
+ the plotting backend (Python or R), which is a blocking gate: it must be
7
+ chosen explicitly before any figure is drawn. The large body of design,
8
+ API, pattern, and QA material stays in on-demand references.
9
+
10
+ always_load:
11
+ # Skill-local core (figure does not use the prose-oriented _shared layer)
12
+ - static/core/contract.md
13
+ - static/core/stance.md
14
+
15
+ axes:
16
+ backend:
17
+ detect: |
18
+ BLOCKING GATE. Determine the plotting backend from an explicit user
19
+ choice or a clearly language-specific input file/workflow. If the user
20
+ has NOT explicitly chosen Python or R, ask exactly one concise question —
21
+ "Python or R?" — and stop. Do not default, do not guess, do not generate
22
+ mock data or scripts before the answer. Only recommend a backend when the
23
+ user explicitly asks you to choose; in that case use
24
+ references/backend-selection.md, state the reason, then proceed.
25
+ Once selected, the backend is exclusive for all drawing, previewing,
26
+ exporting, and visual QA.
27
+ values:
28
+ python: static/fragments/backend/python.md
29
+ r: static/fragments/backend/r.md
30
+ multi: false
31
+
32
+ references:
33
+ on_demand:
34
+ - condition: convert a user request into core conclusion, evidence hierarchy, panel map, and review-risk checks
35
+ path: references/figure-contract.md
36
+ - condition: user has not chosen Python/R, asks for a recommendation, or a mixed Python/R workflow is possible
37
+ path: references/backend-selection.md
38
+ - condition: user chooses R or provides R scripts/templates/data
39
+ path: references/r-workflow.md
40
+ - condition: adapt a user-provided or private R template collection without exposing source paths
41
+ path: references/r-template-index.md
42
+ - condition: before final delivery, revision package, microscopy/blot figure, or journal-specific audit
43
+ path: references/qa-contract.md
44
+ - condition: typography, color theory, layout rationale, export policy
45
+ path: references/design-theory.md
46
+ - condition: Python PALETTE, helper function signatures, validation rules
47
+ path: references/api.md
48
+ - condition: "Python layout patterns: hero panels, legend-only axes, dark image plates, asymmetric layouts"
49
+ path: references/common-patterns.md
50
+ - condition: "real Nature page archetypes: schematic-led composites, dark image plates, clinical triptychs, asymmetric hero layouts"
51
+ path: references/nature-2026-observations.md
52
+ - condition: writing or auditing figure/table legend text — Fig. N | title, panel style, stats in legend, Source Data boilerplate, attribution
53
+ path: references/figure-legend-conventions.md
54
+ - condition: "end-to-end walkthroughs: bars, trends, heatmaps"
55
+ path: references/tutorials.md
56
+ - condition: "radar, 3D sphere, fill_between, scatter patterns"
57
+ path: references/chart-types.md
58
+ - condition: bundled figures4papers Python scripts and output previews for concrete pattern adaptation
59
+ path: references/demos.md