Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add example to :class:`FunctionGraph` (#1637)

Ujjayanta4cbba8cd2916
diff --git a/manim/mobject/functions.py b/manim/mobject/functions.py
index 738f74f83..4b8d0e4eb 100644
--- a/manim/mobject/functions.py
+++ b/manim/mobject/functions.py
@@ -103,6 +103,34 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):
class FunctionGraph(ParametricFunction):
+ """A :class:`ParametricFunction` that spans the length of the scene by default.
+
+ Examples
+ --------
+ .. manim:: ExampleFunctionGraph
+ :save_last_frame:
+
+ class ExampleFunctionGraph(Scene):
+ def construct(self):
+ cos_func = FunctionGraph(
+ lambda t: np.cos(t) + 0.5 * np.cos(7 * t) + (1 / 7) * np.cos(14 * t),
+ color=RED,
+ )
+
+ sin_func_1 = FunctionGraph(
+ lambda t: np.sin(t) + 0.5 * np.sin(7 * t) + (1 / 7) * np.sin(14 * t),
+ color=BLUE,
+ )
+
+ sin_func_2 = FunctionGraph(
+ lambda t: np.sin(t) + 0.5 * np.sin(7 * t) + (1 / 7) * np.sin(14 * t),
+ x_range=[-4, 4],
+ color=GREEN,
+ ).move_to([0, 1, 0])
+
+ self.add(cos_func, sin_func_1, sin_func_2)
+ """
+
def __init__(self, function, x_range=None, color=YELLOW, **kwargs):
if x_range is None: