Convert Figma logo to code with AI

3b1b logomanim

Animation engine for explanatory math videos

61,870
5,759
61,870
416

Top Related Projects

20,911

A community-maintained Python framework for creating mathematical animations.

matplotlib: plotting with Python

16,136

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!

3,289

Main repository for Vispy

Quick Overview

Manim is a Python library created by 3Blue1Brown for creating mathematical animations. It provides a powerful and flexible framework for generating high-quality, customizable animations that can be used in educational, research, or presentation contexts.

Pros

  • Powerful Animation Capabilities: Manim allows for the creation of complex, dynamic animations with a wide range of mathematical and visual elements.
  • Customizable and Extensible: The library is highly customizable, allowing users to create their own animation scenes, objects, and behaviors.
  • Versatile Output Formats: Manim can export animations in various formats, including video files, GIFs, and SVG images.
  • Active Community: The project has a growing community of users and contributors, providing support, resources, and ongoing development.

Cons

  • Steep Learning Curve: Manim has a relatively steep learning curve, especially for users unfamiliar with Python programming and animation concepts.
  • Performance Limitations: Depending on the complexity of the animations, Manim may struggle with performance, especially on lower-end hardware.
  • Limited Documentation: While the project has some documentation, it can be sparse or outdated in certain areas, making it challenging for new users to get started.
  • Dependency on Python: Manim is a Python-based library, which may be a limitation for users who prefer to work in other programming languages.

Code Examples

Here are a few examples of how to use Manim to create animations:

  1. Animating a Sine Wave:
from manim import *

class SineWave(Scene):
    def construct(self):
        axes = Axes(x_range=[-PI, PI], y_range=[-2, 2])
        graph = axes.plot(lambda x: np.sin(x), color=BLUE)
        self.play(Create(axes), Create(graph))
        self.wait(2)

This code creates a scene with an x-y coordinate system and a sine wave graph, and then animates the creation of these elements.

  1. Animating a Geometric Transformation:
from manim import *

class SquareToCircle(Scene):
    def construct(self):
        square = Square(side_length=2)
        circle = Circle(radius=1)
        self.play(Transform(square, circle))
        self.wait(2)

This code animates the transformation of a square into a circle, demonstrating Manim's ability to handle geometric transformations.

  1. Animating Text and Equations:
from manim import *

class TextAndEquations(Scene):
    def construct(self):
        text = Text("Manim is awesome!")
        equation = MathTex(r"\int_a^b f(x)\,dx")
        self.play(Write(text))
        self.wait(1)
        self.play(Transform(text, equation))
        self.wait(2)

This code shows how to animate the display of text and mathematical equations using Manim.

Getting Started

To get started with Manim, follow these steps:

  1. Install Python 3.7 or later on your system.
  2. Install the Manim library using pip:
    pip install manim
    
  3. Create a new Python file (e.g., my_animation.py) and import the necessary Manim modules:
    from manim import *
    
  4. Define a new scene class that inherits from Scene and implement the construct() method, where you can create and animate your objects:
    class MyAnimation(Scene):
        def construct(self):
            # Add your animation code here
            pass
    
  5. Run the animation using the Manim CLI:
    manim my_animation.py MyAnimation
    
    This will generate a video file of your animation.

For more detailed instructions, documentation, and examples, please refer to the Manim GitHub repository.

Competitor Comparisons

20,911

A community-maintained Python framework for creating mathematical animations.

Pros of manim

  • More active development and frequent updates
  • Larger community support and contributions
  • Better documentation and examples

Cons of manim

  • Potentially less stable due to frequent changes
  • May have compatibility issues with older projects
  • Steeper learning curve for beginners

Code Comparison

manim:

from manim import *

class SquareToCircle(Scene):
    def construct(self):
        square = Square()
        circle = Circle()
        self.play(Transform(square, circle))

3b1b/manim:

from manimlib.imports import *

class SquareToCircle(Scene):
    def construct(self):
        square = Square()
        circle = Circle()
        self.play(Transform(square, circle))

The code structure is similar, but manim uses a more modern import style and may have slight differences in class and method names. manim also offers more customization options and features, which may require additional code for advanced animations.

matplotlib: plotting with Python

Pros of matplotlib

  • Widely adopted and well-established library for static plotting
  • Extensive documentation and large community support
  • Integrates seamlessly with NumPy and other scientific Python libraries

Cons of matplotlib

  • Less suitable for creating animations and interactive visualizations
  • Steeper learning curve for complex visualizations
  • Limited built-in support for 3D animations

Code Comparison

matplotlib:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()

manim:

from manim import *

class SineWave(Scene):
    def construct(self):
        ax = Axes(x_range=[-1, 7], y_range=[-2, 2])
        sine = ax.plot(lambda x: np.sin(x), color=BLUE)
        self.play(Create(ax), Create(sine))

manim is designed for creating mathematical animations and explanatory videos, while matplotlib focuses on static plotting and basic animations. manim offers more dynamic and visually appealing animations out of the box, but matplotlib is more versatile for general-purpose data visualization tasks.

16,136

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!

Pros of Plotly

  • Interactive and web-based visualizations
  • Extensive library of chart types and customization options
  • Easier learning curve for those familiar with Python and data analysis

Cons of Plotly

  • Less suitable for complex animations or mathematical visualizations
  • May require additional setup for offline use or embedding in other applications
  • Limited control over fine-grained animation details

Code Comparison

Plotly example:

import plotly.graph_objects as go

fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()

Manim example:

from manim import *

class BarChart(Scene):
    def construct(self):
        chart = BarChart(values=[2, 3, 1])
        self.play(Create(chart))

Plotly focuses on creating static or interactive charts with minimal code, while Manim is designed for creating complex mathematical animations and requires more setup and scripting. Plotly is better suited for data visualization and dashboards, whereas Manim excels in educational content and mathematical explanations.

3,289

Main repository for Vispy

Pros of Vispy

  • Broader scope: Vispy is a general-purpose scientific visualization library, while Manim focuses on mathematical animations
  • Better performance: Vispy leverages GPU acceleration for faster rendering of large datasets
  • More active development: Vispy has more recent commits and a larger contributor base

Cons of Vispy

  • Steeper learning curve: Vispy requires more low-level programming knowledge compared to Manim's higher-level abstractions
  • Less specialized for math: Manim offers more built-in mathematical objects and animations out of the box

Code Comparison

Vispy example:

from vispy import app, scene
canvas = scene.SceneCanvas(keys='interactive')
view = canvas.central_widget.add_view()
scatter = scene.visuals.Markers()
scatter.set_data(pos, symbol='o', size=10, color=(1, 0, 0, 0.5))
view.add(scatter)
app.run()

Manim example:

from manim import *
class PointExample(Scene):
    def construct(self):
        dot = Dot(point=[0, 0, 0], color=RED)
        self.add(dot)
        self.play(dot.animate.shift(RIGHT))

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

pypi version MIT License Manim Subreddit Manim Discord docs

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

Note, there are two versions of manim. This repository began as a personal project by the author of 3Blue1Brown for the purpose of animating those videos, with video-specific code available here. In 2020 a group of developers forked it into what is now the community edition, with a goal of being more stable, better tested, quicker to respond to community contributions, and all around friendlier to get started with. See this page for more details.

Installation

WARNING: These instructions are for ManimGL only. Trying to use these instructions to install ManimCommunity/manim or instructions there to install this version will cause problems. You should first decide which version you wish to install, then only follow the instructions for your desired version.

Note: To install manim directly through pip, please pay attention to the name of the installed package. This repository is ManimGL of 3b1b. The package name is manimgl instead of manim or manimlib. Please use pip install manimgl to install the version in this repository.

Manim runs on Python 3.7 or higher.

System requirements are FFmpeg, OpenGL and LaTeX (optional, if you want to use LaTeX). For Linux, Pango along with its development headers are required. See instruction here.

Directly

# Install manimgl
pip install manimgl

# Try it out
manimgl

For more options, take a look at the Using manim sections further below.

If you want to hack on manimlib itself, clone this repository and in that directory execute:

# Install manimgl
pip install -e .

# Try it out
manimgl example_scenes.py OpeningManimExample
# or
manim-render example_scenes.py OpeningManimExample

Directly (Windows)

  1. Install FFmpeg.
  2. Install a LaTeX distribution. MiKTeX is recommended.
  3. Install the remaining Python packages.
    git clone https://github.com/3b1b/manim.git
    cd manim
    pip install -e .
    manimgl example_scenes.py OpeningManimExample
    

Mac OSX

  1. Install FFmpeg, LaTeX in terminal using homebrew.

    brew install ffmpeg mactex
    
  2. Install latest version of manim using these command.

    git clone https://github.com/3b1b/manim.git
    cd manim
    pip install -e .
    manimgl example_scenes.py OpeningManimExample
    

Anaconda Install

  1. Install LaTeX as above.
  2. Create a conda environment using conda create -n manim python=3.8.
  3. Activate the environment using conda activate manim.
  4. Install manimgl using pip install -e ..

Using manim

Try running the following:

manimgl example_scenes.py OpeningManimExample

This should pop up a window playing a simple scene.

Look through the example scenes to see examples of the library's syntax, animation types and object types. In the 3b1b/videos repo, you can see all the code for 3blue1brown videos, though code from older videos may not be compatible with the most recent version of manim. The readme of that repo also outlines some details for how to set up a more interactive workflow, as shown in this manim demo video for example.

When running in the CLI, some useful flags include:

  • -w to write the scene to a file
  • -o to write the scene to a file and open the result
  • -s to skip to the end and just show the final frame.
    • -so will save the final frame to an image and show it
  • -n <number> to skip ahead to the n'th animation of a scene.
  • -f to make the playback window fullscreen

Take a look at custom_config.yml for further configuration. To add your customization, you can either edit this file, or add another file by the same name "custom_config.yml" to whatever directory you are running manim from. For example this is the one for 3blue1brown videos. There you can specify where videos should be output to, where manim should look for image files and sounds you want to read in, and other defaults regarding style and video quality.

Documentation

Documentation is in progress at 3b1b.github.io/manim. And there is also a Chinese version maintained by @manim-kindergarten: docs.manim.org.cn (in Chinese).

manim-kindergarten wrote and collected some useful extra classes and some codes of videos in manim_sandbox repo.

Contributing

Is always welcome. As mentioned above, the community edition has the most active ecosystem for contributions, with testing and continuous integration, but pull requests are welcome here too. Please explain the motivation for a given change and examples of its effect.

License

This project falls under the MIT license.