DEV Community

Cover image for I Spent 5 Years Making Math Animations in Python. Here's Everything I Wish I Knew on Day One.
Sohaib Hassan
Sohaib Hassan

Posted on

I Spent 5 Years Making Math Animations in Python. Here's Everything I Wish I Knew on Day One.

A complete, honest guide to building 3Blue1Brown-style math animations with Manim CE — from zero setup to your first polished scene. No fluff, just what actually works.

The first time I tried to make a math animation, I spent four hours staring at an error message I didn't understand.

No one warned me about LaTeX dependencies. No one explained the difference between Text and MathTex. No one told me why my equation was rendering in the wrong position — or why my animation was playing twice — or why the camera was cutting off half my scene.

I figured it out eventually. But it took months, not days.

If you're reading this, you probably want to create math animations. Maybe you've watched 3Blue1Brown explain calculus and thought "I want to make something like that." Maybe you teach mathematics and you're tired of static diagrams that put students to sleep. Maybe you're just curious whether Python can actually produce beautiful, publication-quality math visuals.

It can. And it's more accessible than you think.

But only if someone shows you where to actually start.


What Is Manim — And Why Does It Matter?

Manim is an open-source Python library built specifically for mathematical animations. Every equation you render is typeset through LaTeX. Every shape, every graph, every transformation is mathematically precise — not visually approximate.

This is what separates Manim from every other animation tool.

When you draw a circle in Manim, it's a perfect circle — defined mathematically, rendered with zero distortion. When you write a quadratic formula, it looks exactly like a published research paper. When you animate a transformation, every frame is calculated programmatically.

This is why educators, researchers, and content creators around the world have adopted it. Not because it's easy — but because nothing else produces results like this.


The Mistake Everyone Makes on Day One

Most beginners open Manim, look at the documentation, and immediately feel overwhelmed.

The documentation is comprehensive — but it's not written for beginners. It assumes you already know what you're looking for. If you don't, you'll spend hours reading without actually building anything.

Here's the truth: you learn Manim by writing scenes, not by reading documentation.

Every concept clicks the moment you run working code and see it render. Not before.

This is why the copy-paste-first approach works so much better than theory-first learning.


What You Actually Need to Get Started

Before writing your first scene, you need four things — and three of them are completely free.

1. Python 3.9 or later
If you already have Python installed, you're halfway there. If not, the official Python website has a one-click installer for every OS.

2. Manim CE v0.20.1

pip install manim==0.20.1
Enter fullscreen mode Exit fullscreen mode

3. A LaTeX DistributionThis is where most beginners get stuck

Manim uses LaTeX to render equations. You need either:

  • MiKTeX (Windows)
  • TeX Live (Mac/Linux)

Both are free. Both take about 15 minutes to set up. Do not skip this step — skipping it is why 80% of "Manim doesn't work" posts exist on forums.

4. VS Code
Any text editor works, but VS Code gives you syntax highlighting, terminal integration, and extensions that make Manim development significantly smoother.

That's the entire setup. No subscriptions. No expensive software. No complicated configuration beyond these four things.


Your First Scene — What It Looks Like

Here is the simplest possible Manim scene. Copy this exactly, save it as first_scene.py, and run it:

from manim import *

class HelloManim(Scene):
    def construct(self):
        equation = MathTex(r"x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}")
        self.play(Write(equation))
        self.wait(2)
Enter fullscreen mode Exit fullscreen mode

Render it with:

manim -pql first_scene.py HelloManim
Enter fullscreen mode Exit fullscreen mode

In under ten seconds, you'll have a video of the quadratic formula writing itself onto the screen — typeset perfectly, animated smoothly.

That's Manim. That's what three lines of actual code produce.

💡 Always use -pql (low quality) while developing. High-quality renders take minutes. Save -pqh for your final output only.


The Five Concepts That Unlock Everything

After years of building animations, I can tell you that 90% of what you'll ever need in Manim comes down to five core concepts.

1. MathTex and Text

MathTex renders LaTeX equations. Text renders plain words. Knowing when to use which — and how to color individual parts of an equation — is the foundation of every math explainer.

# Correct — renders LaTeX
equation = MathTex(r"E = mc^2")

# Wrong for equations — won't render LaTeX
label = Text("E = mc^2")
Enter fullscreen mode Exit fullscreen mode

2. Shapes and Geometry

Circles, squares, triangles, lines, arcs — all mathematically defined, all fully customizable. Once you understand how positioning works in Manim, placing objects exactly where you want them takes seconds.

circle = Circle(radius=1, color=BLUE)
square = Square(side_length=2, color=GREEN)
square.next_to(circle, RIGHT, buff=0.5)
Enter fullscreen mode Exit fullscreen mode

3. Animations and Transforms

Write, Create, FadeIn, Transform, ReplacementTransform — these are the verbs of Manim. Each one does something specific, and choosing the right one makes the difference between an animation that feels natural and one that feels jarring.

self.play(Write(equation))           # draws stroke by stroke
self.play(FadeIn(circle))            # fades in from transparent
self.play(Transform(square, circle)) # morphs one shape into another
Enter fullscreen mode Exit fullscreen mode

4. NumberPlane and Graphs

Plotting functions in Manim is remarkably clean. Define your axes, pass a lambda function, and Manim draws it — with full control over color, range, and style.

axes = Axes(x_range=[-3, 3], y_range=[-1, 9])
graph = axes.plot(lambda x: x**2, color=YELLOW)
self.play(Create(axes), Create(graph))
Enter fullscreen mode Exit fullscreen mode

5. Updaters and ValueTracker

This is where Manim becomes truly powerful. Updaters let objects respond dynamically to changing values — this is how you create animations where a tangent line moves along a curve, or a point traces a parametric path in real time.

tracker = ValueTracker(0)
dot = always_redraw(
    lambda: Dot(axes.c2p(tracker.get_value(), tracker.get_value()**2), color=RED)
)
self.play(tracker.animate.set_value(2), run_time=3)
Enter fullscreen mode Exit fullscreen mode

The Common Mistakes That Cost Beginners Hours

I made every single one of these. You don't have to.

Mistake What to do instead
Rendering high quality every time Use -pql while building. Switch to -pqh only for the final render.
Not using VGroup for positioning Group related objects with VGroup — positioning a group is infinitely cleaner than positioning each object individually.
Hardcoding coordinates Use .next_to(), .shift(), .move_to(). Your layout will survive any change you make.
Using Text for equations If your equation looks wrong — jagged, unstyled, broken — you're almost certainly using Text when you should be using MathTex.
One long construct() method Break your scene into helper methods. A readable scene is a maintainable scene — especially when you return to it three weeks later.

A Complete Working Example — From Zero to Polished

Here's a scene that combines everything above. Copy it, run it, and modify it as your own starting template:

from manim import *

class QuadraticExplainer(Scene):
    def construct(self):
        # Title
        title = Text("Solving a Quadratic Equation", font_size=36)
        self.play(Write(title))
        self.wait(1)
        self.play(title.animate.to_edge(UP))

        # Standard form
        standard = MathTex(r"ax^2 + bx + c = 0", font_size=48)
        self.play(Write(standard))
        self.wait(1)

        # Transform to quadratic formula
        formula = MathTex(
            r"x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}",
            font_size=48
        )
        self.play(ReplacementTransform(standard, formula))
        self.wait(2)

        # Highlight the discriminant
        formula[0][9:19].set_color(YELLOW)
        discriminant_label = Text("discriminant", font_size=24, color=YELLOW)
        discriminant_label.next_to(formula, DOWN)
        self.play(Write(discriminant_label))
        self.wait(2)
Enter fullscreen mode Exit fullscreen mode

Run with:

manim -pql scene.py QuadraticExplainer
Enter fullscreen mode Exit fullscreen mode

Where to Go From Here

Manim has a learning curve — but it's not as steep as it looks from the outside. The moment your first animation renders, something shifts. You stop seeing it as code and start seeing it as a creative tool.

The path forward is simple: build scenes. Start with something small — an equation, a shape, a simple transform. Then add complexity one layer at a time.

I spent years on this path. I documented everything — every mistake, every shortcut, every pattern I kept returning to — into a structured beginner handbook:

📘 Manim CE v0.20.1 Beginner Handbook

Ten complete chapters. Copy-paste-ready code for every concept above. Common mistakes pre-fixed before you hit them. 60 pages. $9.

If you want to see what Manim looks like in practice before committing to anything, the animations are here:

📱 @plotlab01 on Instagram


Start building. The best math animation you'll ever make is the next one.


About the author: Sohaib Hasan is a Mathematics Lecturer with 9 years of experience and 1,500+ students taught. He creates 3Blue1Brown-style math animations using Python and Manim, and shares them at @plotlab01.

Top comments (0)