Py Math Viz
Use Python to produce clean, readable plots and export to PNG by default.
Assumptions (this workspace):
- - Preferred interpreter: INLINECODE0
- Libraries:
matplotlib, seaborn, numpy (already), opencv-python-headless (installed)
Defaults (quality rules)
- - Output: PNG,
dpi>=200, white background - Always label axes; add title if it helps
- Use legend when multiple series exist (and place it so it doesn’t cover data)
- Avoid overlap:
- prefer
constrained_layout=True and/or
plt.tight_layout()
- rotate dense x-ticks, shorten tick labels
- increase figure size instead of cramming
- - Use consistent styling:
-
seaborn.set_theme(style="whitegrid")
- colorblind-friendly palette if unsure
Quick start (script)
Render a plot from a JSON spec.
To keep the workspace root clean, write outputs into out/ (or out/_scratch/ for throwaway experiments):
CODEBLOCK0
Then send out/plots/plot.png (Telegram: use the message tool with filePath).
Plot spec
The spec is intentionally small.
Read:
- -
references/spec.md — schema + examples - INLINECODE15 — recipes index (points to JSON specs / seaborn snippets / image tiling)
OpenCV helpers
Tile multiple PNGs into one (for comparisons):
CODEBLOCK1
When NOT to use
- - Interactive dashboards (Plotly/Dash) unless explicitly asked
- 3D/mesh-heavy rendering (use specialized tools if needed)
Py Math Viz
使用Python生成清晰、可读的图表,并默认导出为PNG格式。
假设条件(当前工作区):
- - 首选解释器:/root/.openclaw/workspace/.venv-math/bin/python
- 库:matplotlib、seaborn、numpy(已安装)、opencv-python-headless(已安装)
默认设置(质量标准)
- - 输出格式:PNG,dpi>=200,白色背景
- 始终标注坐标轴;如有必要添加标题
- 存在多个数据系列时使用图例(并放置在不遮挡数据的位置)
- 避免重叠:
- 优先使用constrained
layout=True和/或plt.tightlayout()
- 旋转密集的x轴刻度,缩短刻度标签
- 增大图形尺寸而非强行压缩
- seaborn.set_theme(style=whitegrid)
- 不确定时使用色盲友好调色板
快速入门(脚本)
根据JSON规范渲染图表。
为保持工作区根目录整洁,将输出写入out/(临时实验可写入out/_scratch/):
bash
/root/.openclaw/workspace/.venv-math/bin/python \
skills/py-math-viz/scripts/plotfromspec.py \
--spec spec.json --out out/plots/plot.png
然后发送out/plots/plot.png(Telegram:使用带filePath参数的message工具)。
图表规范
规范设计得尽量精简。
请阅读:
- - references/spec.md — 模式与示例
- references/quick-recipes.md — 配方索引(指向JSON规范/ seaborn代码片段/图像拼接)
OpenCV辅助工具
将多个PNG拼接为一个(用于对比):
bash
/root/.openclaw/workspace/.venv-math/bin/python \
skills/py-math-viz/scripts/tile_images.py \
--out tiled.png img1.png img2.png img3.png
不适用场景
- - 交互式仪表盘(Plotly/Dash),除非明确要求
- 3D/网格密集型渲染(如有需要请使用专用工具)