Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions skills-bundled/nature-figure/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,29 @@ axes:
Once selected, the backend is exclusive for all drawing, previewing,
exporting, and visual QA.
values:
python: static/fragments/backend/python.md
r: static/fragments/backend/r.md
python: static/fragments/backend/python.md
r: static/fragments/backend/r.md
multi: false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align multi under the backend axis

With only three leading spaces, this multi key is neither inside backend nor aligned with the other axes entries, which makes the manifest invalid YAML. When the catalog loads, serde_yaml::from_str in parse_skill fails and silently falls back to manifestNoAxes, so nature-figure loses the required backend/data_type chips and all on-demand references.

Useful? React with 👍 / 👎.


data_type:
detect: |
Optional. The user may specify the type of scientific data they are
plotting (e.g. FTIR, XRD, TGA, CV). If provided, use the domain-specific
guidance injected in the instruction to set correct axis directions,
units, annotations, and conventions for that data type. If not provided,
proceed with general plotting best practices.
values:
general: 通用数据
spectroscopy.ftir: FTIR 红外光谱
spectroscopy.raman: Raman 拉曼光谱
spectroscopy.uvvis: UV-Vis 紫外可见光谱
spectroscopy.xrd: XRD X射线衍射
spectroscopy.xps: XPS 光电子能谱
spectroscopy.pl: PL 光致发光光谱
thermal.tga: TGA 热重分析
thermal.dsc: DSC 差示扫描量热
electrochem.cv: CV 循环伏安
electrochem.eis: EIS 电化学阻抗
multi: false

references:
Expand Down
52 changes: 52 additions & 0 deletions skills-bundled/nature-figure/static/fragments/backend/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,58 @@ def save_pub_py(fig, filename, dpi=600):

Use `text.usetex = True` only when LaTeX is installed and math-rich labels are required.

## Export plot parameters (mandatory)

Every figure script must also emit `plot_spec.json` and `plot_data.json` alongside the rendered image. These two files let the Nature App chart editor adjust visual details (colors, fonts, line widths, axis ranges, legend, spines) in real time via local matplotlib re-rendering — no LLM round-trip needed.

```python
import json

def export_plot_params(spec: dict, data: dict, prefix: str = ""):
"""Export structured parameters for the Nature App chart editor."""
with open(f"{prefix}plot_spec.json", "w", encoding="utf-8") as f:
json.dump(spec, f, ensure_ascii=False, indent=2)
with open(f"{prefix}plot_data.json", "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
```

Call `export_plot_params(spec, data)` at the end of the script, right before or after `save_pub_py`. The `spec` and `data` dicts must follow this schema (camelCase keys are optional in the Python dict; the editor reads snake_case as shown):

**`plot_spec` — all visual parameters that can be fine-tuned:**

```json
{
"schema_version": 1,
"chart_type": "line",
"title": "Figure title",
"x_label": "Time", "y_label": "Absorbance",
"x_unit": "s", "y_unit": "a.u.",
"style": {
"figure_size": [8, 5], "dpi": 150,
"font_family": "serif", "font_size": 12,
"grid": true, "grid_alpha": 0.3,
"legend": {"enabled": true, "location": "best"},
"spines": {"enabled": true, "width": 1.2, "color": "#333333"}
}
}
```

**`plot_data` — the actual plotted series:**

```json
{
"schema_version": 1,
"series": [
{"name": "Sample A", "x": [0, 1, 2, 3], "y": [0.1, 0.5, 0.8, 0.3],
"color": "#1a1a1a", "line_width": 2.0, "visible": true},
{"name": "Sample B", "x": [0, 1, 2, 3], "y": [0.2, 0.6, 0.9, 0.4],
"color": "#c73e3a", "line_width": 1.5, "visible": true}
]
}
```

Set `chart_type` to `"line"`, `"bar"`, `"heatmap"`, or `"line_dual_y"` so the editor loads the correct render template. Extract `x` and `y` arrays from the same data you plotted. If a panel has many series, include only the major ones (the editor is for style fine-tuning, not data exploration). For multi-panel figures, export the parameters of the primary panel.

## Going deeper

- `references/api.md` — Python PALETTE, helper function signatures, validation rules.
Expand Down
24 changes: 24 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ serde_json = "1"
serde_yaml = "0.9"
uuid = { version = "1", features = ["v4"] }
dashmap = "6"

base64 = "0.22"
tempfile = "3"
csv = "1.3"
Loading