Manim Tutorial Logo

Olivier Leblanc and Jérome Eertmans
IEEE Student Branch, October 18th 2022
Song: "Savfk - Instructions For Living A Life", under a Creative Commons (CC BY 4.0) license.
Your browser does not support the video element.

Table of Contents¶

  1. What is Manim?
  2. Manim vs ManimGL
  3. How and when to use Manim
  4. Additional tools

Foreword¶

Slides, code and documentation are available in open source. See last slide.

1. What is Manim?¶

Grant Sanderson

3Blue1Brown logo

3Blue1Brown channel

1. What is Manim?¶

To quote 3Blue1Brown:

Manim is an engine for precise programmatic animations, designed for creating explanatory math videos.

Our definition:

Manim is a Python tool that facilitates creating math-related videos.

Did you just say Python?¶

"I don't know anything about Python"

  • One of the easiest programming languages to learn
  • Many examples to learn from

"I don't like programming"

  • Creating animation requires very basic programming knowledge

"I usually run into troubles when installing Python modules"

  • Manim works on Windows, macOS, and Linux. Its installation is relatively easy and well documented

Manim's ABC¶

A. Create a file with scene(s)¶

# scenes.py
from manim import *

class SquareToCircle(Scene):
    def construct(self):
        circle = Circle(color=RED)
        square = Square()     

        self.play(Create(square))
        self.play(Transform(square, circle))
        self.play(FadeOut(square))

B. Render the scene(s)¶

manim scenes.py SquareToCircle

C. Watch the video!¶

Your browser does not support the video element.

Motivation¶

In a few lines of code, Manim can create nice and precise animations, facilitating scientific communication.

  • If a picture is worth a thousand words, what about a video?
  • Not limited to pure mathematics

Motivation: example¶

How to explain the Newton-Raphson's iterative method, used to find a root some function $f$?

$$ x_{k+1} = x_{k} - \frac{f(x_k)}{f'(x_k)} $$
Your browser does not support the video element.

2. Manim vs ManimGL¶

Manim Google Search Results

A bit of History¶

  • March 2015: first video by 3b1b, already using Manim
  • August 2018: 3b1b announced in a FAQ the existence of Manim
  • November 2019: 3b1b/manim is made publicly available
  • May 2020: ManimCommunity/manim fork is created

Manim 3Blue1Brown Edition¶

Manim GL Website

Goal:

  • match 3b1b's needs (at a given time)

Manim Community Edition¶

Manim Comunity Website

Goals:

  • easier to use
  • more stable over time
  • well documented
  • community driven

Comparison¶



Manim 3Blue1Brown
Manim Community
Short name
ManimGL
Manim (or ManimCE)
Command name
manimgl
manim
Python module
manimlib
manim

What to choose¶

Reasons to prefer Manim:

  • Easier cross-platform installation.
  • Does not require installing OpenGL.
  • Maintained by the community. Hence, more stable accross time, meaning that your recently created code is more likely to still work in 2 years with Manim than with ManimGL.
  • Very good documentation, see here.

Reasons to prefer ManimGL:

  • You want to reproduce some of 3b1b's videos, available on GitHub.
  • You need features that are (currently) only available with ManimGL.

3. How and when to use Manim¶

Prerequisites¶

  • Python >= 3.8 installed
  • Basic knowledge in Python, git, $\LaTeX$ and command line

See GitHub README.

Installation¶

Follow the guide, e.g., for Manim:
  • Windows
    • Required Dependencies
    • Optional Dependencies
    • Working with Manim
  • MacOS
    • Required Dependencies
    • Optional Dependencies
    • Working with Manim
  • Linux
    • Required Dependencies
    • Optional Dependencies
Linux Installation Guidelines

Creating a scene¶

# myfile.py
from mamim import *


class MyScene(Scene):
    def construct(self):
        square = Square()

        self.play(Create(square))
        self.play(square.animate.rotate(90 * DEGREES))
        self.play(square.animate.set_color(BLUE))
        self.play(Circumscribe(square, Circle))
        self.play(Uncreate(square))

Rendering the scene¶

From the ManimCommunity/manim repository:

Manim Command Line's How To

Your browser does not support the video element.

Not limited to rendering videos¶

Additionally, Manim can render images (e.g., see first slide) or gif.

It can also render 3D videos...¶

Your browser does not support the video element.

Or animate SVG files!¶

Image 1
Image 2
Image 3

Or animate SVG files!¶

Your browser does not support the video element.

Then, what's next?¶

Create more advanced animation, and get inspiration from others, see:

  • Made with Manim, a collection of content creators utilizing the power of Manim
  • Reducible, a YouTuber that utilizes Manim for its videos
    YouTube Channel Subscribers
  • Summer of Math Exposition #SoME2 Youtube hashtag, few hundreds of videos using Manim
  • the Manim subreddit for questions and inspirations
    Manim Subreddit
  • the Manim Community discord for questions and inspirations
    Discord

When to use Manim?¶

"Is Manim for everyone?"

  • Yes, we believe most students and professors can benefit from using Manim

"Is Manim for every presentation?"

  • No, Manim is best used when animations make things clearer to the audience

"What should I be aware of?"

  • Creating animations can take a lot of time (designing and rendering)

"When is Manim particularly useful?"

  • In small conference talks (~ 10 min.), educational videos, blog posts, ...

4. Additional tools¶

Manim Plugins¶

Many plugins were created by users, some of which can be found on https://plugins.manim.community/.

We particularly like:

  • Manim Physics, a physics simulation plugin for Manim
  • Chanim, an animation engine for explanatory chemistry videos
  • ManimML, a project focusing on visualizations of common Machine Learning concepts
  • Manim Automata, to render Finite State Machines
  • Manim GearBox, to animate gearboxes

Using Manim inside Jupyter¶

This presentation uses Manim inside Jupyter Notebook cells.

%%manim SquareToCircle


class SquareToCircle(Scene):
    def construct(self):
        circle = Circle(color=RED)
        square = Square()

        self.play(Create(square))
        self.play(Transform(square, circle))
        self.play(FadeOut(square))

The Manim Community wrote a comprehensive tutorial on how to use Manim inside a Jupyter Notebook!

NOTE: this feature is only available with Manim, not ManimGL

Interactive presentation with Manim Slides¶

Remember root finding example from earlier?

What if we could pause the video whenever we want? Go backward, forward, reverse, and so on?

With Manim Slides, you can transform any Manim / ManimGL scene into a PowerPoint-like presentation!

With only one change, turn your video into a slides presentation!¶

from manim import *
from manim_slides import Slide

class RootExample(Scene): RootExample(Slide): def construct(self): # Not shown: constructing axes, labels, graph, dots, etc. self.add(ax, labels, graph, dot) # Add plot to scene self.wait() # Wait for some time self.pause() self.play(Create(tangent)) # Animate tanget creation self.pause() self.play(Write(fraction)) # Animate fraction writing self.pause()
while abs(f(x)) > 1e-6: # Until convergence dx = -f(x) / df(x) x += dx # Not shown: new dest., and creating horiz. arrow self.play(Create(direction)) # Animate arrow creation self.play(...) # Animate dot's displacement and arrow's fading self.pause()
self.wait(5) # Wait for some time

Demo time!¶

Thank you for listening!¶



GitHub repository
    
Presentation slides online
https://github.com/jeertmans/manim-tutorial
https://eertmans.be/manim-tutorial