math-graph
Skill1 starsChanged 59 days agoMITView on GitHub
数学函数图像绘制技能:把函数曲线、参数曲线与标注点渲染成 300x300 手绘风 PNG,用于课程笔记配图。当用户提到画函数图像、画个图、画抛物线、画单位圆、画椭圆、函数曲线、坐标图、标注点、plot、graph 等时使用。流程:写 spec 文件(curves 与 points 两个列表)→ 用 tools/mathgraph.py 渲染 → 目视自检 → 得到同名 300x300 PNG。内置默认:无网格、坐标轴带箭头并标 x/y/O、曲线半透明、标注在点的右侧且带白色描边、标签一律用抽象符号($f(x)$、$p(x_0, y_0)$,不写数值)、轻手绘抖动。spec 格式与示例见 references/spec.md;依赖 matplotlib。
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Treasoni/kaoyan_skillstheir own version, first seen Jul 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Treasoni/kaoyan_skills★ 19same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- pic2pptSkill
- subtitle-translateSkill
- tax-filingSkill
The file
Files
数学函数图像绘制(300x300 · 轻手绘)
依赖(首次使用前确认)
绘图依赖 matplotlib(仓库中唯一需要第三方库的技能)。缺失时工具会给出中文提示而不是堆栈:
pip install matplotlib默认样式(已内置,不要每次重新指定)
| 项 | 值 |
| 输出 | 仅 PNG,精确 300x300 像素,白底 |
| 线条 | 轻手绘抖动 + 圆头笔触 |
| 曲线 | 半透明,压在标注文字上时文字仍清晰 |
| 网格线 | 不画 |
| 坐标轴 | 带箭头的直线,标 x、y,原点标 O |
| 点的标注 | 位于点的右侧 |
| 标注符号 | 抽象符号 f(x)、p(x_0, y_0),不出现具体数值 |
这些观感参数集中在 ${CLAUDE_SKILL_DIR}/tools/mgconfig.py,要改观感改那里,不要在 spec 里逐次覆盖。
绘制流程(三步)
写 spec 文件:在目标 PNG 同目录新建
<名字>.graph.py,只写数据、不写绘图代码。最小形态就是两个列表:# -*- coding: utf-8 -*- curves = [dict(expr="x**2", label="$f(x)$")] points = [dict(at=(0, 0), label="$p(x_0, y_0)$")]完整字段、三种曲线形式(显式 / 隐函数 / 参数方程)和可照抄的配方见
${CLAUDE_SKILL_DIR}/references/spec.md。- 渲染:
python "${CLAUDE_SKILL_DIR}/tools/mathgraph.py" "<spec 路径>" -o "<输出.png>"省略-o时输出到 spec 同目录同名(circle.graph.py→circle.png)。 - 目视自检:用 Read 工具查看生成的 PNG,按下节清单逐项核对;不合格就改 spec 或
tools/mgconfig.py再渲染。
标注写法(这条最容易做错)
标注一律用抽象符号,坐标值只体现在点的位置上,不写进文字:
- 对:
"$p(x_0, y_0)$"、"$f(x)$"、"$C$" - 错:
"$(2, 4)$"、"f(2)"、"x = 2"
数学排版走 matplotlib 自带的 mathtext(Computer Modern),不需要也不依赖 LaTeX。手绘感来自线条抖动,字形保持教科书数学体——不要为了「手绘」把字体改成手写体,那会破坏下标和斜体。
完成自检(每张图都要做)
用 Read 打开 PNG,逐条确认:
- 尺寸是 300x300(脚本已在 stdout 报出,异常时用
python -c "from PIL import Image; print(Image.open('x.png').size)"复核) - 没有网格线、没有刻度、没有边框
- 线条有轻微抖动、端点是圆的,但整体干净——不是毛刺噪点
- 曲线是半透明的;曲线穿过标注时,文字仍清晰可读(有白色描边)
- 点的标注在点的右侧;标注之间、标注与轴名之间不重叠、不紧贴
- 文字全是
f(x)/p(x_0, y_0)这类抽象符号,没有任何具体数值 - 坐标轴有箭头,
x在右端、y在上端、原点有O - 没有内容被画布边缘裁切
常见问题
- 圆/椭圆被画成了另一个形状:spec 里漏了
aspect = "equal"。坐标区是正方形,只有两轴跨度相等时数据单位才等长。画几何形状必须填这个字段(见references/spec.md)。 - 渐近线函数(tan、1/x)视野被撑爆:不给
xlim/ylim时渲染器会按分位裁剪,正常不会爆;若仍不满意,直接写死ylim。 - 标签挤在一起:渲染器已做自动避让(点标注优先,曲线名次之)。仍不理想时,减少同图的曲线数量,或把曲线名去掉、只保留点标注。
- 想改观感:改
tools/mgconfig.py里的SKETCH(抖动幅度/波长)与ALPHA_CURVE(透明度),改完全局生效。 - 出图不稳定:抖动在 Agg 后端执行,随机源不在 Python 层,无法用种子控制;实测同一份 spec 每次渲染字节一致。相关说明见
tools/mgconfig.py。
边界与限制
- 本技能只做函数曲线、参数曲线、点及其标注、带箭头坐标轴。
- 不做切线/割线、阴影区域、区间括号、双 y 轴、图例框、动画——需要这些时按实际需求单独处理,不要硬套本技能。
- 输出只有静态 PNG,不做 SVG/PDF;要矢量图或动画请用 manim(本机已装)。
- spec 文件里只能使用
references/spec.md列出的数学函数,不能 import 其他模块。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

