首页
/ ManimCE 函数绘图实战:从 Axes 到 3D 曲面,把数学可视化写进 OpenMontage 视频管线

ManimCE 函数绘图实战:从 Axes 到 3D 曲面,把数学可视化写进 OpenMontage 视频管线

2026-09-08 14:08:27作者:郜逊炳

本文围绕 Manim Community Edition(ManimCE)的函数绘图能力展开:如何在 Axes 坐标系上绘制一元函数与参数曲线、标注函数、填充曲线下面积、构造黎曼矩形、用 ValueTracker 驱动动态图形,以及在 ThreeDScene 中绘制曲面。这些内容既可直接用于书写数学讲解视频场景,也能通过 OpenMontage 的 math_animate 工具与 manimce-best-practices 技能库落地为真实产线能力。读完本文你将掌握 ManimCE 图表绘制的完整 API 用法、常用参数语义与工程级实践准则。

本仓库把 ManimCE 绘图最佳实践沉淀在技能文件 .agents/skills/manimce-best-practices/SKILL.md 中,并配套了可直接渲染的完整示例 examples/graph_plotting.py;而在生产管线一侧,tools/graphics/math_animate.py 是一个免 API Key、本地渲染的 ManimCE 数学动画工具。本文以技能库中的绘图规则文档 rules/graphing.md 为骨架,结合上述源码逐层展开。

环境与渲染:先跑通第一个场景

在进入图形 API 之前,先确认你的渲染环境是 Manim Community Edition 而非 3b1b 的 ManimGL 版本。两者最容易混淆:ManimCE 使用 from manim import *manim CLI,而 ManimGL 使用 from manimlib import *manimgl CLI。技能文档明确给出了区分表:

特性 Manim Community 3b1b/ManimGL
导入 from manim import * from manimlib import *
CLI manim manimgl
数学文本 MathTex(r"\pi") Tex(R"\pi")
场景基类 Scene InteractiveScene
PyPI 包 manim manimgl

安装与自检:

pip install manim
manim checkhealth

如果 manim 命令找不到(Windows 常见),改用 python -m manim。若文字渲染失败,优先排查 manimpango 的安装。渲染质量由 -q 标志控制,SKILL.md 中的速查命令是:

manim -pql scene.py MyScene    # Preview low quality(开发调试)
manim -pqh scene.py MyScene    # Preview high quality
manim --format gif scene.py    # 输出 GIF
manim checkhealth              # 校验安装
manim plugins -l               # 列出插件

OpenMontage 中的实际渲染设定

在 OpenMontage 的产线语境下,质量档位被抽象成了 math_animate 工具的 quality 参数。查看 tools/graphics/math_animate.py 中的 QUALITY_PRESETS,可以确认档位到 CLI 标志的映射关系:

档位 Manim 标志 输出规格 math_animate 中的用途
low -ql 854x480 / 15fps 开发、快速验证
medium -qm 1280x720 / 30fps 草稿(工具默认值)
high -qh 1920x1080 / 60fps 标准输出
4k -qk 3840x2160 / 60fps 高规格归档
preview -ql --format gif 854x480 / 15fps 预览动图

math_animateinput_schema 要求提供 scene_code(一段定义 Manim 场景类的 Python 代码)、可选的 scene_namequality,渲染超时阈值为 300 秒。需要注意一个重要的安全边界:调用方提供的 scene_code 属于本地代码执行边界,工具内部通过静态扫描(_scan_scene_code)阻断 ossubprocesssocket 等危险导入与危险标识符,并以显式的 allow_unsafe_code 作为 opt-out——该逻辑由 tests/tools/test_math_animate_safety.py 覆盖验证。它并非沙箱,仅是纵深防御。

面向 OpenMontage 的视频输出(YouTube landscape 1920x1080/30fps),可在 manim.cfg 中用如下自定义配置渲染后再转码:

[CLI]
pixel_width = 1920
pixel_height = 1080
frame_rate = 30

坐标轴基础:Axes 与其坐标系方法

一切函数绘图都建立在坐标系之上。最基本的用法是创建 Axes 并直接添加到场景:

from manim import *

class BasicPlot(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-2, 8])
        graph = axes.plot(lambda x: x**2, color=BLUE)
        self.add(axes, graph)

x_range=[min, max, step]y_range=[min, max, step] 控制数值范围,第三个元素是可选步长;x_length/y_length 则控制坐标轴在画面上的物理长度。更完整的定制来自 rules/axes.md,其中包含 axis_configx_axis_config/y_axis_config 的细分控制:

from manim import *

class CustomAxes(Scene):
    def construct(self):
        axes = Axes(
            x_range=[-5, 5, 1],      # [min, max, step]
            y_range=[-3, 3, 1],
            x_length=10,             # 屏幕上的物理长度
            y_length=6,
            axis_config={
                "color": BLUE,
                "include_tip": True,
                "include_numbers": True,
            },
            x_axis_config={
                "numbers_to_include": [-4, -2, 0, 2, 4],
            },
            y_axis_config={
                "numbers_to_include": [-2, 0, 2],
            },
        )
        self.add(axes)

配套示例 examples/graph_plotting.py 中的 BasicAxes 类展示了「创建坐标轴 → 添加轴标签」的标准开场流程:

class BasicAxes(Scene):
    """Basic axes setup and labeling."""
    def construct(self):
        axes = Axes(
            x_range=[-3, 3, 1],
            y_range=[-2, 2, 1],
            x_length=8,
            y_length=5,
            axis_config={
                "include_tip": True,
                "include_numbers": True,
            },
        )
        x_label = axes.get_x_axis_label("x")
        y_label = axes.get_y_axis_label("y")

        self.play(Create(axes), Write(x_label), Write(y_label))
        self.wait()

轴标签也支持数学对象,例如 get_x_axis_label(MathTex(r"\theta"))get_y_axis_label(MathTex(r"f(\theta)"))

坐标系转换方法:c2p / p2c / i2gp

Axes 的核心价值是管理「数学坐标 ↔ 屏幕坐标」的换算,任何定位工作都应交给坐标方法,而不是手工换算:

axes = Axes(x_range=[-5, 5], y_range=[-3, 3])

# c2p = coords_to_point:数学坐标 (x, y) → 屏幕点
point = axes.c2p(2, 1)

# p2c = point_to_coords:屏幕点 → 数学坐标
coords = axes.p2c(point)

# i2gp = input_to_graph_point:给定函数曲线与 x 值 → 曲线上点(绘图高频方法)
graph = axes.plot(lambda x: x**2)
pt = axes.i2gp(2, graph)

NumberPlane(带网格线)、ComplexPlane(复数平面,n2p/p2n)、NumberLine(数轴)属于同一坐标系家族。例如向场景中投一个点的写法是 Dot(plane.c2p(2, 3), color=RED);用 NumberPlane 做向量演示能直观展示网格形变。坐标轴的间距美学经验是:x_range/y_range 的比例要与 x_length/y_length 的比例一致,否则图形会被拉伸失真;轴上的数字刻度也不要铺太满,避免视觉噪声。

一元函数绘图:plot() 参数全解

axes.plot(func, ...) 接受一个可调用对象(通常是 lambda)把每个 x 映射到 y,随后根据 x_range 对函数进行采样并生成 VMobject 曲线。规则文档中的 PlotParameters 展示了域裁剪与样式的核心参数:

from manim import *

class PlotParameters(Scene):
    def construct(self):
        axes = Axes(x_range=[-5, 5], y_range=[-2, 2])

        graph = axes.plot(
            lambda x: np.sin(x),
            x_range=[-PI, PI],    # 限制定义域(裁剪出无歧义的图形区间)
            color=YELLOW,
            stroke_width=4,
        )

        self.add(axes, graph)

关键参数说明:

  • function(位置参数):接受 x 返回 y 的 Python 可调用对象。除了 lambda,numpy 的 np.sin/np.cos 这类 ufunc 可以直接传入(见下面多函数示例)。
  • x_range:绘图采样域,与坐标轴范围无关。它对「存在不连续点或未定义区间的函数」至关重要——例如绘制 tan(x) 或带渐近线的函数时,缩小 x_range 到每个连续分支上,可以避免连接线越过渐近线形成假象。
  • color / stroke_width:曲线颜色与描边粗细。ManimCE 内置 BLUEREDGREENYELLOW 等常量,并可用 _A_E 后缀取明度变化。

多函数同轴

把多条曲线画在同一坐标系上,是函数对比、讲解交点、演示平移缩放的基础。同一坐标系里的每个 plot 独立采样,颜色区分是默认的语义手段:

from manim import *

class MultiplePlots(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-2, 10])

        sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)
        cos_graph = axes.plot(lambda x: np.cos(x), color=RED)
        quad_graph = axes.plot(lambda x: x**2, color=GREEN)

        self.add(axes, sin_graph, cos_graph, quad_graph)

MultipleFunctions 类展示了更贴近演示的做法:用 x_range=[-2*PI, 2*PI] 限定采样域并把函数区间拉满,然后分步 Create 并搭配 MathTex 图例:

sine = axes.plot(np.sin, color=BLUE, x_range=[-2 * PI, 2 * PI])
cosine = axes.plot(np.cos, color=RED, x_range=[-2 * PI, 2 * PI])

sin_label = MathTex(r"\sin(x)", color=BLUE).to_corner(UR)
cos_label = MathTex(r"\cos(x)", color=RED).next_to(sin_label, DOWN)

self.play(Create(axes))
self.play(Create(sine), Write(sin_label))
self.play(Create(cosine), Write(cos_label))
self.wait()

给曲线加标签:get_graph_label

曲线本身不含语义。规则文档推荐用 axes.get_graph_label(graph, label, x_val, direction) 把标签「挂」到曲线上指定 x 值处,direction 控制标签相对该点的方位(如 UR 表示右上方)。ManimCE 的 get_graph_label 内部会先用 i2gp 求曲线上对应点,再按 direction 偏移,因此标签天然跟随曲线位置,无需手工换算坐标:

from manim import *

class GraphLabels(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-2, 10])
        graph = axes.plot(lambda x: x**2, color=BLUE)

        label = axes.get_graph_label(
            graph,
            label=MathTex("y = x^2"),
            x_val=2,
            direction=UR
        )

        self.add(axes, graph, label)

如果希望标签颜色与曲线一致,可以给 MathTexcolor 参数。与 get_graph_label 互补的两类标注能力:一是用 MathTex 直接 next_to/to_corner 摆放图例(多函数场景常用);二是绘制指向特定点的辅助线。CoordinateLabeling 类演示了用 axes.c2p 定位点与 DashedLine 画投影参考线、再在轴旁放坐标标签的完整「标点」套路:

func = axes.plot(lambda x: np.sqrt(x), color=BLUE, x_range=[0, 4])
x_val = 2
y_val = np.sqrt(2)

point = Dot(axes.c2p(x_val, y_val), color=RED)
h_line = DashedLine(axes.c2p(0, y_val), axes.c2p(x_val, y_val), color=GREY)
v_line = DashedLine(axes.c2p(x_val, 0), axes.c2p(x_val, y_val), color=GREY)

x_label = MathTex("2").next_to(axes.c2p(x_val, 0), DOWN)
y_label = MathTex(r"\sqrt{2}").next_to(axes.c2p(0, y_val), LEFT)

参数曲线:plot_parametric_curve 与 ParametricFunction

当 y 无法写成 x 的函数(圆、闭合曲线、李萨如曲线等)时,需要使用参数方程。在坐标系上使用 axes.plot_parametric_curve(func, t_range, color),其中 func 接收参数 t,返回 np.array([x(t), y(t), z(t)])

from manim import *

class ParametricExample(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-3, 3])

        # 圆:x = cos(t), y = sin(t)
        curve = axes.plot_parametric_curve(
            lambda t: np.array([np.cos(t), np.sin(t), 0]),
            t_range=[0, 2 * PI],
            color=YELLOW
        )

        self.add(axes, curve)

t_range 控制参数扫描区间,即曲线的「行程」。改变参数方程与区间即可生成丰富形态:

# Lissajous 曲线(频率比 3:2)
curve = axes.plot_parametric_curve(
    lambda t: np.array([np.sin(3*t), np.sin(2*t), 0]),
    t_range=[0, 2*PI],
)

# 螺旋(半径随时间线性增大)
curve = axes.plot_parametric_curve(
    lambda t: np.array([t*np.cos(t), t*np.sin(t), 0]),
    t_range=[0, 4*PI],
)

# 心形曲线(经典参数式,整体缩放 1/10 以适应坐标范围)
curve = axes.plot_parametric_curve(
    lambda t: np.array([
        16 * np.sin(t)**3,
        13*np.cos(t) - 5*np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t),
        0
    ]) / 10,
    t_range=[0, 2*PI],
)

配套示例 ParametricCurve 类还展示了「圆 → 李萨如曲线」的视觉切换——两条曲线分别 Create 之后用 Transform 完成形态演变,适合演示参数关系的变化:

self.play(Create(circle))
self.wait()
self.play(Transform(circle, lissajous))

ImplicitFunction 类进一步说明一个常见思路:隐式方程(如圆 x^2 + y^2 = 4)在 ManimCE 中没有内建隐式曲线函数,把它改写成参数方程plot_parametric_curve 是最直接解法,同时用 MathTex 标注原方程:

circle = axes.plot_parametric_curve(
    lambda t: np.array([2 * np.cos(t), 2 * np.sin(t), 0]),
    t_range=[0, 2 * PI],
    color=BLUE
)
equation = MathTex(r"x^2 + y^2 = 4", color=BLUE).to_corner(UR)

无坐标轴的独立参数曲线:ParametricFunction

如果只是想在场景里画一条不带坐标系的曲线,直接用 ParametricFunction(Mobject 级构造函数),不必依赖 Axes

from manim import *

class StandaloneParametric(Scene):
    def construct(self):
        curve = ParametricFunction(
            lambda t: np.array([np.cos(t), np.sin(t), 0]),
            t_range=[0, 2*PI],
            color=BLUE
        )
        self.add(curve)

极坐标曲线(进阶补充)

坐标绘图并不限于直角系。示例 PolarPlot 类使用 PolarPlaneplot_polar_graph 直接绘制极径函数 r = f(θ)

polar_plane = PolarPlane(radius_max=3, size=6)

# 心形线 r = 1 + sin(θ)
cardioid = polar_plane.plot_polar_graph(
    lambda theta: 1 + np.sin(theta),
    theta_range=[0, 2 * PI],
    color=BLUE
)

# 三瓣玫瑰线 r = 2·cos(3θ)(θ∈[0, π] 即闭合)
rose = polar_plane.plot_polar_graph(
    lambda theta: 2 * np.cos(3 * theta),
    theta_range=[0, PI],
    color=RED
)

积分可视化:面积填充与黎曼矩形

曲线下面积:get_area

讲解定积分时,常用半透明色块填充曲线与 x 轴之间的区域。axes.get_area(graph, x_range, color, opacity) 接收已绘制的曲线、积分区间与填充样式:

from manim import *

class AreaUnderCurve(Scene):
    def construct(self):
        axes = Axes(x_range=[-1, 5], y_range=[-1, 10])
        graph = axes.plot(lambda x: x**2, x_range=[0, 3], color=BLUE)

        # 填充曲线下、x∈[0,2] 的区域
        area = axes.get_area(
            graph,
            x_range=[0, 2],
            color=BLUE,
            opacity=0.5
        )

        self.add(axes, graph, area)

示例 AreaUnderCurve 类把面积图与积分记号 \int_1^3 \frac{x^2}{2} \, dx 组合呈现:先画坐标轴与曲线,FadeIn(area) 淡入色块,最后 Write(integral) 写出积分式。这样「阴影面积 = 定积分值」的对应关系一目了然。

黎曼矩形:get_riemann_rectangles

用矩形逼近面积、演示黎曼和收敛,是微积分讲解的经典桥段。axes.get_riemann_rectangles(graph, x_range, dx, ...) 按区间宽度 dxx_range 内生成矩形堆:

from manim import *

class RiemannRectangles(Scene):
    def construct(self):
        axes = Axes(x_range=[-1, 5], y_range=[-1, 10])
        graph = axes.plot(lambda x: x**2, color=BLUE)

        rects = axes.get_riemann_rectangles(
            graph,
            x_range=[0, 3],
            dx=0.5,
            color=YELLOW,
            stroke_width=1
        )

        self.add(axes, graph, rects)

RiemannSum 类演示了更具教学效果的分辨率递进:依次以 dx = 1 → 0.5 → 0.25 生成矩形并不断 Transform,观众能直观看到矩形逼近曲线、误差收缩的过程:

dx_values = [1, 0.5, 0.25]
for dx in dx_values:
    rects = axes.get_riemann_rectangles(
        func,
        x_range=[1, 3],
        dx=dx,
        color=BLUE,
        fill_opacity=0.5,
        stroke_width=1,
    )
    if dx == 1:
        self.play(Create(rects))
    else:
        self.play(Transform(rects, rects))
    self.wait()

让图形动起来:Create 绘制动画与 ValueTracker 驱动

曲线被「画」出来

Create 从路径起始点沿曲线扫出图形,是图表出场最自然的方式。配合 run_time 控制节奏:

from manim import *

class AnimatedGraph(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-2, 2])
        self.add(axes)

        graph = axes.plot(lambda x: np.sin(x), color=BLUE)

        # 动画绘制曲线
        self.play(Create(graph), run_time=3)

曲线上运动的点:ValueTracker + i2gp

需要表现「x 变化时点在曲线上滑动」时,用 ValueTracker 保存 x 值,用 always_redraw 让点持续重算位置。i2gp(x, graph) 负责把 x 映射到曲线上对应点——这正是它比 c2p 更适合曲线跟随的原因:你不需要手写 y 的表达式:

from manim import *

class MovingPointOnGraph(Scene):
    def construct(self):
        axes = Axes(x_range=[-3, 3], y_range=[-2, 2])
        graph = axes.plot(lambda x: np.sin(x), color=BLUE)

        # 跟随曲线滑动的点
        x_tracker = ValueTracker(-3)

        dot = always_redraw(lambda: Dot(
            axes.i2gp(x_tracker.get_value(), graph),
            color=YELLOW
        ))

        self.add(axes, graph, dot)
        self.play(x_tracker.animate.set_value(3), run_time=4)

AnimatedGraph(示例文件内)是参数驱动的进阶版本:用 ValueTracker(1) 保存振幅 Aalways_redraw 里实时重绘 axes.plot(lambda x: A * sin(x)),并让角落的 A = ... 读数同步更新,然后连续 play(amplitude.animate.set_value(...)) 改变振幅。它演示了「绘图 API + updater 机制 = 动态函数形态」的通用组合,适合表现参数对曲线形状的影响:

amplitude = ValueTracker(1)

graph = always_redraw(
    lambda: axes.plot(
        lambda x: amplitude.get_value() * np.sin(x),
        color=BLUE,
        x_range=[-3, 3]
    )
)

amp_text = always_redraw(
    lambda: MathTex(f"A = {amplitude.get_value():.1f}").to_corner(UR)
)

self.add(axes, graph, amp_text)
self.play(amplitude.animate.set_value(2), run_time=2)

其他相关可视化技巧

  • 切线演示TangentLine 类用「导数求斜率 → 点斜式直线 → 二次 plot」直观呈现切线与斜率标注,斜率为 lambda x: 4 * (x - 2) + 4(在 x=2 处斜率 4)。
  • 散点标注:把若干数学点聚合成 VGroup 再统一添加,例如 VGroup(*[Dot(axes.c2p(x, y), color=YELLOW) for x, y in points])

三维曲面:ThreeDScene 与 plot_surface

当要表达的核心概念是曲面、体积或三维关系时,把场景基类换成 ThreeDScene,配合 ThreeDAxesplot_surface

from manim import *

class SurfacePlot(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()

        surface = axes.plot_surface(
            lambda u, v: np.sin(u) * np.cos(v),
            u_range=[-PI, PI],
            v_range=[-PI, PI],
            colorscale=[BLUE, GREEN, YELLOW],
        )

        self.set_camera_orientation(phi=75*DEGREES, theta=-45*DEGREES)
        self.add(axes, surface)

要点说明:

  • plot_surface 的函数签名为 f(u, v) → zu_range/v_range 给出两个参数方向上的扫描范围,colorscale 让高度差通过颜色渐变呈现。
  • 相机姿态由 set_camera_orientation(phi, theta) 指定,DEGREES 是角度换算常量。phi=75° 相当于略带俯视,theta=-45° 给出 3/4 视角。
  • ThreeDAxes 同样支持 x_range/y_range/z_rangex_length/y_length/z_length 的定制(见 rules/axes.mdThreeDAxesExample)。

规则文档在「何时用 3D」上保持了克制:3D 应仅在空间关系本身就是主题(曲面、体积、法向量、轨道观测)时使用,并让相机环绕去揭示隐藏结构;若只是普通函数图形,默认留在 2D。仓库产线技能 skills/creative/manim-usage.md 补充了性能提示:ManimCE 的 3D 走 CPU Cairo 渲染,比 2D 慢约 5–10 倍,3D 场景务必用 -ql 快速迭代再升档成片。

工程级最佳实践

规则文档结尾给出五条经验法则,结合仓库示例与产线约定扩展如下:

  1. 为不连续函数显式设置 x_range:采样区间要避开未定义区域,防止折线跨越渐近线产生错误图形。域裁剪(domain clipping)是 plot 最值得用足的能力。
  2. get_graph_label 标注函数:它会通过 i2gp 自动把标签定位到曲线上的指定 x_val 处并沿 direction 偏移,比手工摆 MathTex 更稳健、可维护。
  3. 曲线颜色与概念语义保持一致:坐标系内多条曲线必须有稳定配色约定。OpenMontage 的产线配色语义(skills/creative/manim-usage.md)可作参考:被求解变量用 YELLOW,矩阵/算子用 RED,特征向量/结果用 TEAL,已知常数用 BLUE_C,标注用 GREEN,弱化背景用 50% 透明 GREY,错误路径用 RED_E。注意同时用明度差异(_A_E)辅助区分,避免只靠红绿区分(色盲友好)。
  4. 曲线上取点统一走 i2gp:它内部完成数学坐标到曲线上点的换算,避免手工求 y 造成与绘制函数不一致。
  5. 用动画呈现曲线创建Create(graph) 比静态 add 更有叙事性。配合 run_timeValueTracker/always_redraw,可表达「绘制」「参数演化」「点沿曲线运动」三类动态。

与节奏相关的产线经验还包括:绘图类揭示动画 run_time 建议 0.8–1.2s,曲线绘制完成后 wait(1.0–2.0s) 再进入下一个概念;遵循「一个场景只讲一个概念、每次最多同时揭示 3–4 个新视觉元素」的节奏约束(3Blue1Brown 约定);复杂列表或栅格揭示使用 LaggedStart 配合 lag_ratio=0.1–0.2。全片默认使用深色背景(BLACK#1a1a2e)以契合视频输出规范。

从规则到产线:这些绘图能力如何被调用

.agents 目录下的技能是一套「Agent 规则库」,graphing.md 正是 manimce-best-practices 的规则分片之一。Agent 触发该技能的典型信号包括:用户提及 "manim"/"Manim Community"/"ManimCE"、代码中出现 from manim import *、运行 manim CLI 命令,或正在编写 Scene/MathTex/Create() 等 ManimCE 类。技能的检索与联调关系为:SKILL.md(总览与导航)→ rules/axes.md(坐标系,graphing 的前置依赖)→ rules/graphing.md(本节主题)→ examples/graph_plotting.py(可直接运行的完整示例)。

完整示例的运行方式在文件 docstring 中写得很清楚:

manim -pql graph_plotting.py SceneName

其中 SceneName 可取 BasicAxesFunctionPlottingMultipleFunctionsAreaUnderCurveNumberPlaneExampleParametricCurveTangentLineAnimatedGraphRiemannSumImplicitFunctionCoordinateLabelingPolarPlot 等类名。如果你想体验 Jupyter 内联渲染,ManimCE 支持 %%manim -qm MyScene cell magic,直接在 notebook cell 中定义 Scene 类并即时渲染。

在生产流水线侧,tools/graphics/math_animate.py 将上述场景代码作为 scene_code 输入交给本地 manim 进程渲染,工具声明依赖 cmd:manim、能力为 render_scene/render_from_code/render_from_template,并声明关联技能 manimce-best-practicesmanim-composer——换言之,本文的函数绘图模式正是该工具期望的输入形态。阅读 tests/tools/test_math_animate_safety.py 可以进一步看到它如何验证恶意 scene_code 被拦截、allow_unsafe_code 如何绕过扫描,理解「场景代码虽是脚本、但运行时边界有明确契约」这一工程约束。

小结

Axes 上的 plot 到参数曲线的 plot_parametric_curve,从面积与黎曼矩形的积分可视化到 ValueTracker 驱动的动态图形,再到 ThreeDScene 的曲面绘制,ManimCE 把「数学对象 → 视觉对象」的映射封装成了一组高度一致、可组合的坐标 API。把它们与仓库中的坐标系规则(rules/axes.md)、完整示例(examples/graph_plotting.py)以及产线渲染工具(tools/graphics/math_animate.py)配合使用,即可在 OpenMontage 中把任意函数、曲线与曲面故事变成可渲染、可编排的数学动画镜头。

登录后查看全文
热门项目推荐
相关项目推荐

项目优选

收起
ops-transformerops-transformer
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
1.16 K
2.78 K
kernelkernel
deepin linux kernel
C
34
18
docsdocs
暂无描述
Markdown
904
5.83 K
ops-nnops-nn
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
934
1.86 K
pytorchpytorch
作为 Ascend for PyTorch 社区的核心组件,TorchNPU 是昇腾专为 PyTorch 打造的深度学习适配插件,使 PyTorch 框架能够直接调用昇腾 NPU,为开发者提供昇腾 AI 处理器的超强算力。
Python
862
1.36 K
jiuwenswarmjiuwenswarm
JiuwenSwarm 是一款基于openJiuwen开发的智能AI Agent,它能够将大语言模型的强大能力,通过你日常使用的各类通讯应用,直接延伸至你的指尖。
Python
3.96 K
1.03 K
ops-mathops-math
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
1.38 K
1.47 K
kernelkernel
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
535
606
AscendNPU-IRAscendNPU-IR
AscendNPU-IR是基于MLIR(Multi-Level Intermediate Representation)构建的,面向昇腾亲和算子编译时使用的中间表示,提供昇腾完备表达能力,通过编译优化提升昇腾AI处理器计算效率,支持通过生态框架使能昇腾AI处理器与深度调优
C++
549
398
leetcodeleetcode
🔥LeetCode solutions in any programming language | 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
Markdown
77
23