Python Manim Math Animations — Core Concepts
What Manim does
Manim (Mathematical Animation Engine) generates video files from Python code. You describe mathematical objects and the animations between them, and Manim renders each frame, composites them, and outputs an MP4 or GIF. The community edition (ManimCE) is the actively maintained fork, installable via pip install manim.
Scenes
Every animation lives inside a Scene subclass. You override the construct method and call animation methods inside it:
The self.play() method queues an animation and renders the frames. self.wait() holds the current state for a duration. When the script runs, Manim processes these calls sequentially and writes the video.
Mobjects
Mobject (mathematical object) is the base class for everything on screen. Key subclasses include:
- Circle, Square, Line, Arrow — geometric primitives
- MathTex, Tex — LaTeX-rendered equations
- Text — plain text using Pango
- NumberPlane, Axes — coordinate systems
- Graph — network/graph theory visualizations
- VGroup — groups of vector Mobjects that move together
Mobjects have properties like position, color, stroke width, and fill opacity. You manipulate them with methods like .shift(), .scale(), .rotate(), and .set_color().
Animation types
Manim ships with dozens of animation classes:
- Create / FadeIn / FadeOut — appearance and disappearance
- Transform — morph one Mobject into another
- ReplacementTransform — morph and swap the reference
- Write — draw a path as if writing by hand
- MoveAlongPath — slide an object along a curve
- Indicate / Wiggle / Flash — emphasis effects
- AnimationGroup / Succession — combine or sequence animations
Each animation interpolates between states over a configurable run_time using an easing function (called a rate_func). Linear, smooth, ease-in-out, and custom curves are all supported.
Camera and positioning
The default camera shows a region roughly 14 units wide and 8 units tall, centered at the origin. Constants like UP, DOWN, LEFT, RIGHT, ORIGIN are unit vectors for positioning:
Objects can be aligned relative to each other with .next_to(), .align_to(), and .arrange().
Rendering pipeline
When you run manim -pql scene.py MyScene, the tool:
- Executes the
constructmethod - For each
self.play()call, interpolates frames at the target FPS - Renders each frame to a PNG using Cairo (2D) or OpenGL (3D)
- Composes PNGs into a video with FFmpeg
- Opens the result in your media player (
-pflag)
Quality flags: -ql (low, 480p), -qm (medium, 720p), -qh (high, 1080p), -qk (4K).
Common misconception
Many people think Manim requires deep math knowledge. It does not. The library renders whatever you put on screen — flowcharts, timelines, code walkthroughs, or simple shapes. LaTeX is optional; Text handles plain strings.
Community vs original
The original Manim (3b1b/manim) is Grant’s personal tool — fast-moving, less documented. ManimCE (ManimCommunity/manim) is stable, well-documented, and pip-installable. For most users, ManimCE is the right choice.
The one thing to remember: Manim turns a Python script into a rendered video by animating mathematical objects through a sequence of transformations — code in, video out, no manual keyframing.
See Also
- Python Arcade Library Think of a magical art table that draws your game characters, listens when you press buttons, and cleans up the mess — that's Python Arcade.
- Python Audio Fingerprinting Ever wonder how Shazam identifies a song from just a few seconds of noisy audio? Audio fingerprinting is the magic behind it, and Python can do it too.
- Python Barcode Generation Picture the stripy labels on grocery items to understand how Python can create those machine-readable barcodes from numbers.
- Python Cellular Automata Imagine a checkerboard where each square follows simple rules to turn on or off — and suddenly complex patterns emerge like magic.
- Python Godot Gdscript Bridge Imagine speaking English to a friend who speaks French, with a translator in the middle — that's how Python talks to the Godot game engine.