### Dataset Description: Manim Code Examples **Overview:** This dataset consists of 210 code examples demonstrating the usage of **Manim**, a powerful mathematical animation engine for creating precise and visually appealing animations. Each example is structured as a JSON object containing three key components: a `prompt`, a `response`, and `metadata`. The dataset serves as a comprehensive resource for learning, teaching, or experimenting with Manim's capabilities in animating mathematical concepts, geometric shapes, and other visual elements. --- ### Structure of the Dataset: Each entry in the dataset follows this format: ```json { "prompt": "A concise description of the task or concept being demonstrated.", "response": "The corresponding Python code snippet using Manim to achieve the described task.", "metadata": { "source": "The URL or reference where the example originates from.", "original_name": "The name or identifier of the specific feature or class being demonstrated." } } ``` --- ### Key Components: 1. **Prompt (`prompt`)**: - A short, descriptive explanation of the animation or feature being showcased. - Provides context for the code snippet and helps users understand its purpose. - Examples: - "Demonstrate how a square's FadeIn animation can be overridden to instead create the shape from scratch." - "Show surrounding rectangle and add three texts over it with Succession animation." 2. **Response (`response`)**: - A Python code snippet written using the Manim library. - Implements the concept or task described in the `prompt`. - Includes imports, custom classes (if necessary), and the main animation logic. - Examples: - Overriding the `FadeIn` animation to use `Create` instead. - Animating a group of dots with varying lag ratios and labeling them. 3. **Metadata (`metadata`)**: - Contains additional information about the source and context of the example. - **Fields**: - `source`: The URL or documentation reference where the example is derived from (e.g., Manim's official documentation). - `original_name`: The name of the specific feature, class, or method being demonstrated (e.g., `Animation`, `Add`, `FadeIn`). --- ### Example Entries: #### Example 1: Overriding Animation ```json { "prompt": "Demonstrate how a square's FadeIn animation can be overridden to instead create the shape from scratch.", "response": "from manim import *\n\nclass MySquare(Square):\n @override_animation(FadeIn)\n def _fade_in_override(self, **kwargs):\n return Create(self, **kwargs)\n\nclass OverrideAnimationExample(Scene):\n def construct(self):\n self.play(FadeIn(MySquare()))", "metadata": { "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.html", "original_name": "animation" } } ``` #### Example 2: Surrounding Rectangle with Succession Animation ```json { "prompt": "Show surrounding rectangle and add three texts over it with Succession animation.", "response": "from manim import *\n\nclass DefaultAddScene(Scene):\n def construct(self):\n text_1 = Text(\"I was added with Add!\")\n text_2 = Text(\"Me too!\")\n text_3 = Text(\"And me!\")\n texts = VGroup(text_1, text_2, text_3).arrange(DOWN)\n rect = SurroundingRectangle(texts, buff=0.5)\n\n self.play(\n Create(rect, run_time=3.0),\n Succession(\n Wait(1.0),\n Add(text_1),\n Wait(1.0),\n Add(text_2, text_3),\n ),\n )\n self.wait()", "metadata": { "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.Add.html", "original_name": "Add" } } ``` #### Example 3: Lag Ratios in Dot Animations ```json { "prompt": "Demonstrate the animation of dot groups with varying lag ratios and vertical shifts, displaying corresponding text labels.", "response": "from manim import *\n\nclass LagRatios(Scene):\n def construct(self):\n ratios = [0, 0.1, 0.5, 1, 2] # demonstrated lag_ratios\n\n # Create dot groups\n group = VGroup(*[Dot() for _ in range(4)]).arrange_submobjects()\n groups = VGroup(*[group.copy() for _ in ratios]).arrange_submobjects(buff=1)\n self.add(groups)\n\n # Label groups\n self.add(Text(\"lag_ratio = \", font_size=36).next_to(groups, UP, buff=1.5))\n for group, ratio in zip(groups, ratios):\n self.add(Text(str(ratio), font_size=36).next_to(group, UP))\n\n #Animate groups with different lag_ratios\n self.play(AnimationGroup(*[\n group.animate(lag_ratio=ratio, run_time=1.5).shift(DOWN * 2)\n for group, ratio in zip(groups, ratios)\n ]))\n\n # lag_ratio also works recursively on nested submobjects:\n self.play(groups.animate(run_time=1, lag_ratio=0.1).shift(UP * 2))", "metadata": { "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.Animation.html", "original_name": "Animation" } } ``` --- ### Use Cases: 1. **Learning Manim**: - Ideal for beginners and intermediate users who want to explore Manim's features through practical examples. - Helps users understand how to implement specific animations and customize them. 2. **Teaching and Tutorials**: - Can be used by educators to create lesson plans or tutorials on mathematical animations. 3. **Experimentation and Prototyping**: - Developers can experiment with the provided code snippets to prototype new animations or modify existing ones. 4. **Documentation and Reference**: - Serves as a supplementary resource for Manim's official documentation, offering concrete examples for each feature. --- ### Dataset Highlights: - **Comprehensive Coverage**: The dataset includes a wide variety of animations, ranging from basic shape manipulations to advanced techniques like overriding animations and recursive lag ratios. - **Real-World Context**: Each example is grounded in a practical use case, making it easier for users to relate the code to real-world applications. - **Traceable Sources**: Every example is linked to its original source, ensuring transparency and enabling users to explore further documentation if needed. --- ### Size and Scope: - **Number of Examples**: 210 - **Primary Library**: Manim - **Programming Language**: Python - **Topics Covered**: - Basic animations (e.g., `FadeIn`, `Create`, `Transform`) - Advanced techniques (e.g., overriding animations, lag ratios) - Scene construction and customization - Text and shape manipulations --- ### Conclusion: This dataset is a valuable resource for anyone interested in mastering Manim or exploring the art of mathematical animations. With its diverse range of examples, clear structure, and traceable sources, it provides a solid foundation for both learning and innovation in the field of animated visualizations. --- license: mit ---