This document will lead you step by step through the necessary procedure to get started with manim for the first time as soon as possible. This tutorial assumes you have already installed manim following the steps in Installation.
To start a new manim video project, all you need to do is choose a single
folder where all of the files related to the video will reside. For this
example, this folder will be called
Every file containing code that produces a video with manim will be stored here, as well as any output files that manim produces and configuration files that manim needs.
In case you like to work with Jupyterlab / Jupyter notebooks, there is good news:
Manim ships with a
%%manim IPython magic command which makes it easy to use
in such a setting as well. Find out more in the
To produce your first scene, create a new file in your project folder called
and copy the following code in it.
from manim import * class SquareToCircle(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
Then open your command line, navigate to your project directory, and execute the following command:
$ manim scene.py SquareToCircle -pql
After showing some output, manim should render the scene into a .mp4 file, and open that file with the default movie player application. You should see a video playing the following animation.
If you see the video and it looks correct, congrats! You just wrote your first manim scene from scratch. If you get an error message instead, or if do not see a video, or if the video output does not look like this, it is likely that manim has not been installed correctly. Please refer to the Troubleshooting page for more information.
Let’s go line by line over the script we just executed to see how manim was able to generate the video.
The first line
from manim import *
imports all of the contents of the library. This is the recommended way of
using manim, as usually in a single script you will be using quite a few names
from the manim namespace. In particular, this line includes all of the names
used in the script:
Now let’s look at the next two lines.
class SquareToCircle(Scene): def construct(self):
Most of the time, the code for scripting an animation with manim will go inside
construct() method of a class that derives from
Scene. Inside this
method, you will create objects, display them on screen, and animate them.
The next two lines create a circle and set its color and opacity.
circle = Circle() # create a circle circle.set_fill(PINK, opacity=0.5) # set the color and transparency
Finally, the last line uses the animation
Create to display the
circle on screen.
self.play(Create(circle)) # show the circle on screen
Our scene is a little basic, so let’s add some bells and whistles. Modify the
scene.py file to contain the following:
from manim import * class SquareToCircle(Scene): def construct(self): circle = Circle() # create a circle circle.set_fill(PINK, opacity=0.5) # set color and transparency square = Square() # create a square square.flip(RIGHT) # flip horizontally square.rotate(-3 * TAU / 8) # rotate a certain amount self.play(Create(square)) # animate the creation of the square self.play(Transform(square, circle)) # interpolate the square into the circle self.play(FadeOut(square)) # fade out animation
And render it using the following command:
$ manim scene.py SquareToCircle -pql
The output should look as follows.
This example shows one of the most basic features of manim: the ability to implement complicated and mathematically-intensive animations (such as cleanly interpolating between two geometric shapes) in very few lines of code.
With a working installation of manim, and the bare basics under your belt, it
is now time to start creating awesome mathematical animations. For a look
under the hood at what manim is doing when rendering the
scene, see the next tutorial A deeper look. For an extensive review of
manim’s features, as well as its configuration and other settings, see the
other Tutorials. For a list of all available features, see the