All skills
adithya-s-k avatar

/manimce-best-practices

@6668663
by Adithya S Kadithya-s-k/manim_skill1.1k stars
94

Trigger when: (1) User mentions "manim" or "Manim Community" or "ManimCE", (2) Code contains `from manim import *`, (3) User runs `manim` CLI commands, (4) Working with Scene, MathTex, Create(), or ManimCE-specific classes. Best practices for Manim Community Edition - the community-maintained Python animation engine. Covers Scene structure, animations, LaTeX/MathTex, 3D with ThreeDScene, camera control, styling, and CLI usage. NOT for ManimGL/3b1b version (which uses `manimlib` imports and `manimgl` CLI).

Use this Skill: https://skilld.dev/gh/adithya-s-k/manim_skill/manimce-best-practices

This session only. Nothing lands on disk.

rulesgraphing.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Graphing Functions

Plot mathematical functions and curves.

Plotting Functions on Axes

from manim import *

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

        # Plot a function
        graph = axes.plot(lambda x: x**2, color=BLUE)

        self.add(axes, graph)

plot() Parameters

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],    # Limit domain
            color=YELLOW,
            stroke_width=4,
        )

        self.add(axes, graph)

Multiple Functions

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)

Adding Labels to Graphs

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)

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

        self.add(axes, graph, label)

Parametric Curves

Plot curves defined by parametric equations.

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

        # Circle: 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)

Parametric Curve Examples

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

# Spiral
curve = axes.plot_parametric_curve(
    lambda t: np.array([t*np.cos(t), t*np.sin(t), 0]),
    t_range=[0, 4*PI],
)

# Heart curve
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],
)

ParametricFunction (standalone)

Create parametric curves without axes:

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)

Area Under Curve

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)

        # Shade area under curve
        area = axes.get_area(
            graph,
            x_range=[0, 2],
            color=BLUE,
            opacity=0.5
        )

        self.add(axes, graph, area)

Riemann Rectangles

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)

Animated Graphing

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)

        # Animate the graph being drawn
        self.play(Create(graph), run_time=3)

Moving Point on Graph

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)

        # Point that follows graph
        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)

3D Surface Plots

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)

Best Practices

  1. Set x_range on plot for discontinuities - Avoid graphing undefined regions
  2. Use get_graph_label for clarity - Label functions on the graph
  3. Match graph color to concept - Consistent color coding
  4. Use i2gp for points on graphs - Automatically handles conversion
  5. Animate graph creation - More engaging than static display

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill is a comprehensive educational resource for the Manim Community Edition library. It provides best practices, templates, and example scripts for creating mathematical animations and visualizations. No security risks or malicious patterns were identified.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    37 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 6668663. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
  • Python
  • manim
  • animation
  • latex
  • mathtex
  • 3d
  • rendering
  • scene
  • visualization

README badge

README badge for adithya-s-k/manim_skill/manimce-best-practices

Provides best practices and patterns for Manim Community Edition, the Python animation library for mathematical visualizations. Covers Scene structure, animations, LaTeX rendering, 3D graphics, positioning, and CLI usage with organized rule files, working examples, and templates.

Generated from the current SKILL.md.

Does this skill cover ManimGL or just Manim Community Edition?
Only Manim Community Edition (ManimCE). It does not apply to ManimGL/3b1b version, which uses `manimlib` imports and the `manimgl` CLI instead.
What topics are included in this skill?
Scene structure, mobjects, animations (creation, transformation, groups), text and LaTeX rendering, styling, positioning, 3D visualization, timing and updaters, camera control, CLI usage, and common geometric shapes.
Does this skill include working examples?
Yes. It includes five complete example files demonstrating basic animations, math visualization, updater patterns, graph plotting, and 3D visualization, plus three scene templates for 2D, camera-controlled, and 3D scenes.
What should I do if text rendering fails in my Manim scripts?
Check your manimpango installation requirements, as text rendering failures often stem from manimpango configuration issues. The skill also recommends running `manim checkhealth` to verify your overall installation.
How do I render a scene with different quality levels?
Use quality flags with the manim CLI: `-ql` for low quality (fast, development), `-qm` for medium, `-qh` for high, and `-qk` for 4K. For example: `manim -pqh scene.py MyScene`.

Generated from the current SKILL.md. These answers refresh after source changes.