FunctionGraph¶
Qualified name: manim.mobject.graphing.functions.FunctionGraph
- class FunctionGraph(function, x_range=None, color=ManimColor('#FFFF00'), **kwargs)[source]¶
Bases:
ParametricFunctionA
ParametricFunctionthat spans the length of the scene by default.Examples
Example: ExampleFunctionGraph ¶
from manim import * 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)
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)Methods
get_functionget_point_from_functionAttributes
alwaysCall a method on a mobject every frame.
animateUsed to animate the application of any method of
self.animation_overridescolordepthThe depth of the mobject.
fill_colorIf there are multiple colors (for gradient) this returns the first one
heightThe height of the mobject.
n_points_per_curvesheen_factorstroke_colorwidthThe width of the mobject.
- Parameters:
function (Callable[[float], Any])
x_range (tuple[float, float] | tuple[float, float, float] | None)
color (ParsableManimColor)
kwargs (Any)
- _original__init__(function, x_range=None, color=ManimColor('#FFFF00'), **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
function (Callable[[float], Any])
x_range (tuple[float, float] | tuple[float, float, float] | None)
color (ParsableManimColor)
kwargs (Any)
- Return type:
None