Grant Sanderson a.k.a. 3blue1brown’s project manim is a curious passion project to create interactive python plot-compatible animations with mathematics, via code. It is youtube-famous. Here is a powerful example of what this tool can do. Most importantly, it makes me feel fancy. Here are some notes and links I need while using it.
- I believe the community edition (source) is recommended for newcomers rather than the more idiosyncratic 31b1 version.
- ManimCommunity/manim: A community-maintained Python framework for creating mathematical animations.
sudo apt install libcairo2-dev libpango1.0-dev ffmpeg # Debian brew install py3cairo ffmpeg pango scipy # macos python -m pip install manim
- Manim Quickstart
- /r/manim the reddit community is very helpful
Tips and tricks
- Moving things to the edge of the screen?
- Manim Tutorial on 2D Graphs
- A deep dive into Manim’s internals
- Manim’s Output Settings
- Manim’s building blocks
- There are z_indexes to allow us to include one thing with another.
- A lot of stuff that is badly explained, or unexplained, in the manual is beautifull demonstrated in the Example Gallery
SVG height is not what it claims
From the documentation one might get the impression that the SVGMobject
width and height parameters set width and height.
Wrong; if I use both they only set the width.
If I wanted to set the height, I needed to use the
def create_person(width=1.5, height=2.6, *_, color=PURPLE): person = SVGMobject( "person.svg", fill_color=color, width=width, height=height, ).set_z_index(0) print("requested dims", width, height, "!=actual dims", person.get_width(), person.get_height()) person = person.stretch_to_fit_width(width).stretch_to_fit_height(height) print("but after stretching we should match", person.get_width(), person.get_height()) return person
- Professionalize the police - by Noah Smith - Noahpinion
- manimml/ManimML: ManimML is a project focused on providing animations and visualizations of common machine learning concepts with the Manim Community Library.
- Matheart/manim-physics: Physics simulation plugin of Manim that can generate scenes in various branches of Physics.
- NeoPlato/manim-livestream: Package that implements livestreaming configurations for Manim.
- ManimCommunity/awesome-manim: A database with many Manim users and content creators
- heejin_park’s Lectures
- naveen521kk/manim-fonts: Use Fonts from Internet With Manim.
- naveen521kk/manim-fontawesome: Font Awesome SVG's for Manim
Secret OpenGL mode
Undocumented, except for the distressingly vague and unofficial Manim OpenGL Renderer Usage Guide.
Fast (notionally) and interactive.
Possibly using OpenGL is as simple as passing the
That does not work for me.
This is how we create a cell that will render itself:
%%manim -v WARNING --progress_bar None CreateCircle class CreateCircle(Scene): def construct(self): circle = Circle() # create a circle circle.set_fill(PINK, opacity=0.5) # set the color and transparency self.play(Create(circle)) # show the circle on screen
-v WARNING and
--progress_bar None are to keep output minimalist.
It is somewhat hard to find documentation for this features by browsing, but it exists under ManimMagic, although there it punts lots of stuff to the manim command line.
Misfeature: Arrow is a thing, but the tip of teh arrow does not inherit the
z_index of the parent.
Checking TipableVMobject we find the correct mitigation is
arrow = Arrow( start=LEFT,, end=RIGHT, color=YELLOW) arrow.z_index = 10 ## tip does not inherit z_index arrow.get_tip().z_index = 10
Fade out everything
self.play( *[FadeOut(mob)for mob in self.mobjects] )
OK, but how do we actually create a video with helpful text etc? People do not often post full examples. Here is one, by Act of Learning.
Quick and dirty presentation by screen capture
Painstakingly editing a video in code is very hi-fi, but also tedious and I am happy to throw away some fidelity in order to get my presentations done.
One quick hack to improve the quality of inference is to use a screen capture tool to record the video as it is being rendered. I use quicktime on macos because that is easy, but there are many alternatives on all OSes; in particular there are fancy video routers which will do live compositing.
To make that fluid there need to be something to play back and pause the video animation; this goes much nicer if there are no annoying “pause” and “play” icons on the screen.
Pro-tip: VLC has a mode without such icons, which are called “on screen display”. They can be disabled in the advanced preferences: see How to disable the pause and play on screen icons.
That done, a screen capture of the important bit of the video playing window is a reasonably seamless way to show off the animation, and it is easy to pause and resume the animation as needed. The resulting video might occasionally be paused in the wrong moment and will have some silly resolution (811 pixels high on min machine) but TBH my years of training is in machine learning not in video production, so they are going to have to pay someone if they want something better.
Want a quirky GUI to present those animations fluidly?
A recent feature tries to make the timing of the animation smoother by easing synchronising a script and a recorded or synthesized voice inside the animation.
I personally am bad at writing scripts, and bad at following scripts, and I usually speak off the cuff, so this does not seem to help me.
OpenGL mode is supposedly interactive:
Adding a line:
self.interactive_embed()within your scene allows you to interact with the scene directly via an IPython shell
However, OpenGL mode does not work for me.
In VS Code
There is an extension apparently for live previewing manim animations.
It doesn’t work for me; for one it seems to use PowerShell, somehow, but then give an error about a missing
/bin/sh. What shell/OS am I even supposed to be using?
No comments yet. Why not leave one?