EXEPERTAI LAB
EXEPERT / DIRECTORY
← Blog

How 3Blue1Brown Animates: Manim, a Text Editor and a Live Python Shell

3Blue1Brown's animations start as Python. A walkthrough of Grant Sanderson's Manim demo with Ben Sparks: which Manim to pick, the highlight-and-run loop with checkpoints, a chaotic Lorenz attractor, equations on a 3D camera move, rendering for Final Cut, and where to start.

Akmal Alif · 11 October 2026 MYT

Ten glowing teal and blue curves trace the two looping lobes of a Lorenz attractor on a dark background, seen from a slightly turned 3D angle with faint axes, each curve ending in a soft glowing dot.

Most video editing starts with footage. 3Blue1Brown's starts with code. The animations on Grant Sanderson's maths channel are made almost entirely in Python with Manim, a library Sanderson started while finishing an undergraduate degree and has grown alongside the channel ever since. In October 2024 Sanderson published a 54-minute behind-the-scenes demo, recorded with Ben Sparks, familiar from many Numberphile videos, that shows the whole loop: an empty scene, a chaotic Lorenz attractor, equations laid over a 3D camera move, and finally an MP4 ready for the editor (3Blue1Brown, 2024).

This post walks through that demo with timestamps that jump to each part. It is paraphrased from the video's English captions, and checked against the code and workflow notes Sanderson publishes on GitHub.

How I animate 3Blue1Brown, a Manim demo with Ben Sparks (3Blue1Brown)The YouTube player loads in privacy-enhanced mode when you press play.Watch on YouTube ↗

Two Manims, and which one to pick

There are two versions of Manim, and the video is upfront about it (watch from 0:54):

  • ManimGL is Sanderson's own library, published as 3b1b/manim on GitHub under the MIT licence. It is the one used for the channel and in this demo, and it gets features as the videos need them: in recent years, an interactive mode and faster OpenGL rendering (3Blue1Brown, n.d.-a).

  • Manim Community is a fork run by a community that wanted a sturdier tool for everyone else, with attention to issues and pull requests, tests and much better documentation. Sanderson recommends that newcomers start there (watch from 2:13; The Manim Community Developers, 2026).

The two share most ideas but not every function name, so code from one may need small changes to run in the other.

Hello world: a scene is a Python class

A scene is a Python class, and everything that draws lives in its construct method. Shapes, text and graphs are all "mobjects", short for mathematical objects. Adding a circle or a square puts it on screen; calling play with an animation, such as Write, animates it instead. Write is the effect anyone who has watched the channel will recognise, with the outline traced on before the fill fades in (watch from 3:03; 7:15).

A core idea of the library is that anything can transform into anything. In the demo the letter H of "Hello world" morphs into a circle. Every animation also has a rate function. The default, smooth, eases in and out, and Sanderson notes that this kind of detail is the difference between making something move and making it look good (watch from 7:52; 9:52).

The live loop: highlight, run, look

The most useful part of the demo for anyone who builds things is the workflow. Sanderson writes in Sublime Text, with a Python shell beside it that is connected to the running scene. Typing a command in that shell changes the scene at once (watch from 2:45; 3:32).

Copying lines into the shell by hand gets old quickly, so a keyboard shortcut does it. Highlight some code, press Command and R, and the selection runs in the scene (watch from 4:28). The README of the 3b1b/videos repository spells out the two pieces underneath, for anyone who wants to rebuild the setup in another editor (3Blue1Brown, n.d.-b):

  1. Running the manimgl command with a file, a scene and the "-se" flag plus a line number drops you into an interactive IPython session at that line, like a debugger.

  2. Inside that session, a checkpoint paste call runs whatever is on the clipboard. If the copied code starts with a comment, the scene's state is saved the first time that comment is seen, and later runs of code with the same comment first rewind to that state.

That second trick matters because 3Blue1Brown scenes are long. Sanderson shows a scene from the holograms video that rendered to a four-and-a-half-minute MP4, all in one class so that every part shares the same variables. Rewinding to a checkpoint lets a section in the middle be tweaked and re-run on its own, much like a cell in a Jupyter notebook, while the scene stays one plain text file (watch from 4:46; 6:15). Variants of the same command run code without animating it, or record it straight to a file (3Blue1Brown, n.d.-b).

Building a Lorenz attractor

The main exercise is the Lorenz attractor, a system of three differential equations that became a founding image of chaos theory (watch from 10:32). The steps are a good tour of how a 3Blue1Brown scene comes together:

  • Borrow the boring part. For the numerical solver, Sanderson asked ChatGPT for boilerplate around SciPy's solve_ivp function, then adapted it. The chatbot's version plotted with Matplotlib; the scene needed Manim (watch from 12:35).

  • Map to the axes. Solution points are in the system's own coordinates, so they go through the 3D axes' coordinates-to-point method before becoming a curve (watch from 16:45).

  • Let the maths set the pace. Drawing the curve with the default smooth rate function distorts the system's real timing. Here the rate function is set to linear, because the motion is the mathematics (watch from 19:25).

  • Show the chaos. Ten starting points that differ by one part in a thousand in one coordinate are drawn together. They travel as one, then fly apart, while all staying on the same strange attractor (watch from 20:22).

  • Track the ends. A glowing dot follows the tip of each curve through an updater, a function that runs on every frame, and a colour gradient keeps the number of colours equal to the number of curves (watch from 23:46; 26:28).

  • Move the camera. Another shortcut copies the camera's current angle as code, and the frame's animate property then turns the view slowly across the whole run, which keeps the depth readable on a flat screen (watch from 34:08).

  • Finish the look. The full curves are hidden and each dot keeps a short, fading tracing tail. With the starting points moved a hundred times closer together, the ten dots take visibly longer to drift apart (watch from 38:14; 39:13).

One line in the demo, which updates the global variables with all the local ones, is there to work around a scoping quirk of the embedded IPython session. Sanderson calls it cursed, explains why it was needed, and shows the cleaner fix: pass the outside variable into the function as a default argument (watch from 28:52; 31:13).

From scene to MP4 to the edit

When a scene is right, it is rendered from the command line: the manimgl command with the file and the scene name. A pre-run pass estimates the length and catches errors before a long render, and another flag writes the result to a file, usually in 4K (watch from 41:42).

Sanderson explains that this is also how Manim used to be used all the time: change the code, render, watch the MP4, repeat. The interactive shell arrived around the time the renderer moved to OpenGL, and Sanderson calls it a fundamental change to the workflow. The editor side is a set of Sublime plugins that send commands to Terminus, a terminal that runs inside Sublime (watch from 43:02). The rendered clips then go into Final Cut for editing (watch from 44:29).

Equations on a 3D scene

The last build adds the Lorenz equations as LaTeX. For typing them, Sanderson recommends Mathpix, which turns a screenshot of an equation into LaTeX (watch from 44:35). Then:

  • Pin it to the camera. Fixing the equations in the frame keeps them in a corner while the 3D camera turns (watch from 45:39).

  • Colour the variables. A tex-to-colour mapping paints every x, y and z in its own colour. Isolating parts of an expression lets them be moved or highlighted later; Sparks remarks that this would be a real pain in most other tools (watch from 46:13).

  • Keep it readable. Adding the equations last puts them in front, and a backstroke with a smaller font size keeps them clear of the curves as the scene plays (watch from 48:03).

Where to start

For getting started, Sanderson points to a few places (watch from 48:43):

  • The example scenes file in the ManimGL repository. One example rearranges an equation with a transform that matches up the underlying strings, TransformMatchingStrings, which also makes anagram animations almost free.

  • The animation folder of the library, which lists every animation that exists, such as FlashAround and Indicate. The Community edition has much fuller documentation of the same ideas (watch from 50:03).

  • The 3b1b/videos repository, which holds the code for the channel's videos, past and present. Its contents are shared under a CC BY-NC-SA 4.0 licence, unlike the MIT-licensed library (3Blue1Brown, n.d.-b).

On tools, Sanderson prefers plain autocomplete from a language server in the editor to GitHub Copilot for Manim work: the request is often easier to express in code than in English (watch from 51:25).

What builders can take from it

The demo is about maths, but the lessons carry over to any creative coding:

  1. Shorten the loop. The biggest change in Sanderson's workflow was not a new feature but going from render-and-watch to highlight-and-run.

  2. Keep long work in one place, with checkpoints. One file per scene, with saved states to rewind to, gives notebook speed without losing a plain, versionable script.

  3. Let the subject decide the motion. Smooth easing is the right default, until the timing itself is the point.

  4. Automate the fiddly parts. Shortcuts that copy a camera angle or run a selection are tiny, and they add up across a long video.

Manim, ManimGL and the 3Blue1Brown videos repository are in the EXEPERT Tools Gallery, alongside other kits for builders and creative coders.

References

3Blue1Brown. (2024, October 12). How I animate 3Blue1Brown, a Manim demo with Ben Sparks [Video]. YouTube. https://www.youtube.com/watch?v=rbu7Zu5X1zI

3Blue1Brown. (n.d.-a). manim: Animation engine for explanatory math videos [Computer software]. GitHub. Retrieved October 11, 2026, from https://github.com/3b1b/manim

3Blue1Brown. (n.d.-b). videos: Code for the manim-generated scenes used in 3blue1brown videos [Computer software]. GitHub. Retrieved October 11, 2026, from https://github.com/3b1b/videos

The Manim Community Developers. (2026). Manim: Mathematical animation framework (Version 0.22.0) [Computer software]. https://www.manim.community/