CoordinateSystem

Qualified name: manim.mobject.coordinate\_systems.CoordinateSystem

class CoordinateSystem(x_range=None, y_range=None, x_length=None, y_length=None, dimension=2)[source]

Bases: object

Abstract class for Axes and NumberPlane

Examples

Example: CoordSysExample

../_images/CoordSysExample-1.png
from manim import *

class CoordSysExample(Scene):
    def construct(self):
        # the location of the ticks depends on the x_range and y_range.
        grid = Axes(
            x_range=[0, 1, 0.05],  # step size determines num_decimal_places.
            y_range=[0, 1, 0.05],
            x_length=9,
            y_length=5.5,
            axis_config={
                "numbers_to_include": np.arange(0, 1 + 0.1, 0.1),
                "font_size": 24,
            },
            tips=False,
        )

        # Labels for the x-axis and y-axis.
        y_label = grid.get_y_axis_label("y", edge=LEFT, direction=LEFT, buff=0.4)
        x_label = grid.get_x_axis_label("x")
        grid_labels = VGroup(x_label, y_label)

        graphs = VGroup()
        for n in np.arange(1, 20 + 0.5, 0.5):
            graphs += grid.get_graph(lambda x: x ** n, color=WHITE)
            graphs += grid.get_graph(
                lambda x: x ** (1 / n), color=WHITE, use_smoothing=False
            )

        # Extra lines and labels for point (1,1)
        graphs += grid.get_horizontal_line(grid.c2p(1, 1, 0), color=BLUE)
        graphs += grid.get_vertical_line(grid.c2p(1, 1, 0), color=BLUE)
        graphs += Dot(point=grid.c2p(1, 1, 0), color=YELLOW)
        graphs += Tex("(1,1)").scale(0.75).next_to(grid.c2p(1, 1, 0))
        title = Title(
            # spaces between braces to prevent SyntaxError
            r"Graphs of $y=x^{ {1}\over{n} }$ and $y=x^n (n=1,2,3,...,20)$",
            include_underline=False,
            font_size=40,
        )

        self.add(title, graphs, grid, grid_labels)

Methods

add_coordinates

Adds labels to the axes.

angle_of_tangent

Returns the angle to the x-axis of the tangent to the plotted curve at a particular x-value.

c2p

Abbreviation for coords_to_point

coords_to_point

get_T_label

Creates a labelled triangle marker with a vertical line from the x-axis to a curve at a given x-value.

get_area

Returns a Polygon representing the area under the graph passed.

get_axes

get_axis

get_axis_labels

Defines labels for the x_axis and y_axis of the graph.

get_center_point

Gets the origin of Axes.

get_derivative_graph

Returns the curve of the derivative of the passed graph.

get_graph

Generates a curve based on a function.

get_graph_label

Creates a properly positioned label for the passed graph, with an optional dot.

get_horizontal_line

A horizontal line from the y-axis to a given point in the scene.

get_implicit_curve

Creates the curves of an implicit function.

get_line_from_axis_to_point

Returns a straight line from a given axis to a point in the scene.

get_lines_to_point

Generate both horizontal and vertical lines from the axis to a point.

get_origin

Gets the origin of Axes.

get_parametric_curve

get_riemann_rectangles

Generates a VGroup of the Riemann Rectangles for a given curve.

get_secant_slope_group

Creates two lines representing dx and df, the labels for dx and df, and

get_vertical_line

A vertical line from the x-axis to a given point in the scene.

get_vertical_lines_to_graph

Obtains multiple lines from the x-axis to the curve.

get_x_axis

get_x_axis_label

Generate an x-axis label.

get_x_unit_size

get_y_axis

get_y_axis_label

Generate a y-axis label.

get_y_unit_size

get_z_axis

i2gp

Alias for input_to_graph_point().

input_to_graph_point

Returns the coordinates of the point on a graph corresponding to an x value.

p2c

Abbreviation for point_to_coords

point_to_coords

slope_of_tangent

Returns the slope of the tangent to the plotted curve at a particular x-value.

add_coordinates(*axes_numbers, **kwargs)[source]

Adds labels to the axes. Use Axes.coordinate_labels to access the coordinates after creation.

Parameters

axes_numbers (Union[Iterable[float], None, Dict[float, Union[str, float, manim.mobject.mobject.Mobject]]]) – The numbers to be added to the axes. Use None to represent an axis with default labels.

Examples

ax = ThreeDAxes()
x_labels = range(-4, 5)
z_labels = range(-4, 4, 2)
ax.add_coordinates(x_labels, None, z_labels)  # default y labels, custom x & z labels
ax.add_coordinates(x_labels)  # only x labels

You can also specifically control the position and value of the labels using a dict.

ax = Axes(x_range=[0, 7])
x_pos = [x for x in range(1, 8)]

# strings are automatically converted into a `Tex` mobject.
x_vals = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
x_dict = dict(zip(x_pos, x_vals))
ax.add_coordinates(x_dict)
angle_of_tangent(x, graph, dx=1e-08)[source]

Returns the angle to the x-axis of the tangent to the plotted curve at a particular x-value.

Examples

ax = Axes()
curve = ax.get_graph(lambda x: x ** 2)
ax.angle_of_tangent(x=3, graph=curve)
# 1.3825747960950903
Parameters
Returns

The angle of the tangent to the curve.

Return type

float

c2p(*coords)[source]

Abbreviation for coords_to_point

get_T_label(x_val, graph, label=None, label_color='#FFFFFF', triangle_size=0.25, triangle_color='#FFFFFF', line_func=<class 'manim.mobject.geometry.Line'>, line_color='#FFFF00')[source]

Creates a labelled triangle marker with a vertical line from the x-axis to a curve at a given x-value.

Parameters
  • x_val (float) – The position along the curve at which the label, line and triangle will be constructed.

  • graph (manim.mobject.functions.ParametricFunction) – The ParametricFunction for which to construct the label.

  • label (Optional[Union[float, str, manim.mobject.mobject.Mobject]]) – The label of the vertical line and triangle.

  • label_color (colour.Color) – The color of the label.

  • triangle_size (float) – The size of the triangle.

  • triangle_color (colour.Color) – The color of the triangle.

  • line_func (manim.mobject.geometry.Line) – The function used to construct the vertical line.

  • line_color (colour.Color) – The color of the vertical line.

Return type

manim.mobject.types.vectorized_mobject.VGroup

Examples

Example: T_labelExample

../_images/T_labelExample-1.png
from manim import *

class T_labelExample(Scene):
    def construct(self):
        # defines the axes and linear function
        axes = Axes(x_range=[-1, 10], y_range=[-1, 10], x_length=9, y_length=6)
        func = axes.get_graph(lambda x: x, color=BLUE)
        # creates the T_label
        t_label = axes.get_T_label(x_val=4, graph=func, label=Tex("x-value"))
        self.add(axes, func, t_label)
Returns

A VGroup of the label, triangle and vertical line mobjects.

Return type

VGroup

Parameters
get_area(graph, x_range=None, color=['#58C4DD', '#83C167'], opacity=0.3, bounded_graph=None, **kwargs)[source]

Returns a Polygon representing the area under the graph passed.

Examples

Example: GetAreaExample

../_images/GetAreaExample-1.png
from manim import *

class GetAreaExample(Scene):
    def construct(self):
        ax = Axes().add_coordinates()
        curve = ax.get_graph(lambda x: 2 * np.sin(x), color=DARK_BLUE)
        area = ax.get_area(
            curve,
            x_range=(PI / 2, 3 * PI / 2),
            color=(GREEN_B, GREEN_D),
            opacity=1,
        )

        self.add(ax, curve, area)
Parameters
  • graph (manim.mobject.functions.ParametricFunction) – The graph/curve for which the area needs to be gotten.

  • x_range (Optional[Tuple[float, float]]) – The range of the minimum and maximum x-values of the area. x_range = [x_min, x_max].

  • color (Union[colour.Color, Iterable[colour.Color]]) – The color of the area. Creates a gradient if a list of colors is provided.

  • opacity (float) – The opacity of the area.

  • bounded_graph (Optional[manim.mobject.functions.ParametricFunction]) – If a secondary graph is specified, encloses the area between the two curves.

  • kwargs – Additional parameters passed to Polygon

Returns

The Polygon representing the area.

Return type

Polygon

Raises

ValueError – When x_ranges do not match (either area x_range, graph’s x_range or bounded_graph’s x_range).

get_axis_labels(x_label='x', y_label='y')[source]

Defines labels for the x_axis and y_axis of the graph. For increased control over the position of the labels, use get_x_axis_label() and get_y_axis_label().

Examples

Example: GetAxisLabelsExample

../_images/GetAxisLabelsExample-1.png
from manim import *

class GetAxisLabelsExample(Scene):
    def construct(self):
        ax = Axes()
        labels = ax.get_axis_labels(
            Tex("x-axis").scale(0.7), Text("y-axis").scale(0.45)
        )
        self.add(ax, labels)
Parameters
Returns

A Vgroup of the labels for the x_axis and y_axis.

Return type

VGroup

get_center_point()[source]

Gets the origin of Axes.

np.ndarray

The center point.

Deprecated

The method CoordinateSystem.get_center_point has been deprecated since v0.10.0 and is expected to be removed after v0.11.0. Use get_origin instead.

Return type

numpy.ndarray

get_derivative_graph(graph, color='#83C167', **kwargs)[source]

Returns the curve of the derivative of the passed graph.

Examples

Example: GetDerivativeGraphExample

../_images/GetDerivativeGraphExample-1.png
from manim import *

class GetDerivativeGraphExample(Scene):
    def construct(self):
        ax = NumberPlane(y_range=[-1, 7], background_line_style={"stroke_opacity": 0.4})

        curve_1 = ax.get_graph(lambda x: x ** 2, color=PURPLE_B)
        curve_2 = ax.get_derivative_graph(curve_1)
        curves = VGroup(curve_1, curve_2)

        label_1 = ax.get_graph_label(curve_1, "x^2", x_val=-2, direction=DL)
        label_2 = ax.get_graph_label(curve_2, "2x", x_val=3, direction=RIGHT)
        labels = VGroup(label_1, label_2)

        self.add(ax, curves, labels)
Parameters
Returns

The curve of the derivative.

Return type

ParametricFunction

get_graph(function, x_range=None, **kwargs)[source]

Generates a curve based on a function.

Warning

This method may not produce accurate graphs since Manim currently relies on interpolation between evenly-spaced samples of the curve, instead of intelligent plotting. See the example below for some solutions to this problem.

Examples

Example: GetGraphExample

../_images/GetGraphExample-1.png
from manim import *

class GetGraphExample(Scene):
    def construct(self):
        # construct the axes
        ax_1 = Axes(
            x_range=[0.001, 6],
            y_range=[-8, 2],
            x_length=5,
            y_length=3,
            tips=False,
        )
        ax_2 = ax_1.copy()
        ax_3 = ax_1.copy()

        # position the axes
        ax_1.to_corner(UL)
        ax_2.to_corner(UR)
        ax_3.to_edge(DOWN)
        axes = VGroup(ax_1, ax_2, ax_3)

        # create the logarithmic curves
        def log_func(x):
            return np.log(x)

        # a curve without adjustments; poor interpolation.
        curve_1 = ax_1.get_graph(log_func, color=PURE_RED)

        # disabling interpolation makes the graph look choppy as not enough
        # inputs are available
        curve_2 = ax_2.get_graph(log_func, use_smoothing=False, color=ORANGE)

        # taking more inputs of the curve by specifying a step for the
        # x_range yields expected results, but increases rendering time.
        curve_3 = ax_3.get_graph(
            log_func, x_range=(0.001, 6, 0.001), color=PURE_GREEN
        )

        curves = VGroup(curve_1, curve_2, curve_3)

        self.add(axes, curves)
Parameters
  • function (Callable[[float], float]) – The function used to construct the ParametricFunction.

  • x_range (Optional[Sequence[float]]) – The range of the curve along the axes. x_range = [x_min, x_max, x_step].

  • kwargs – Additional parameters to be passed to ParametricFunction.

Returns

The plotted curve.

Return type

ParametricFunction

get_graph_label(graph, label='f(x)', x_val=None, direction=array([1., 0., 0.]), buff=0.25, color=None, dot=False, dot_config=None)[source]

Creates a properly positioned label for the passed graph, with an optional dot.

Examples

Example: GetGraphLabelExample

../_images/GetGraphLabelExample-1.png
from manim import *

class GetGraphLabelExample(Scene):
    def construct(self):
        ax = Axes()
        sin = ax.get_graph(lambda x: np.sin(x), color=PURPLE_B)
        label = ax.get_graph_label(
            graph=sin,
            label= MathTex(r"\frac{\pi}{2}"),
            x_val=PI / 2,
            dot=True,
            direction=UR,
        )

        self.add(ax, sin, label)
Parameters
  • graph (manim.mobject.functions.ParametricFunction) – The curve.

  • label (Union[float, str, manim.mobject.mobject.Mobject]) – The label for the function’s curve. Defaults to MathTex for str and float inputs.

  • x_val (Optional[float]) – The x_value along the curve that positions the label.

  • direction (Sequence[float]) – The cartesian position, relative to the curve that the label will be at –> LEFT, RIGHT

  • buff (float) – The distance between the curve and the label.

  • color (Optional[colour.Color]) – The color of the label. Defaults to the color of the curve.

  • dot (bool) – Whether to add a dot at the point on the graph.

  • dot_config (Optional[dict]) – Additional parameters to be passed to Dot.

Returns

The positioned label and Dot, if applicable.

Return type

Mobject

get_horizontal_line(point, **kwargs)[source]

A horizontal line from the y-axis to a given point in the scene.

Examples

Example: GetHorizontalLineExample

../_images/GetHorizontalLineExample-1.png
from manim import *

class GetHorizontalLineExample(Scene):
    def construct(self):
        ax = Axes().add_coordinates()
        point = ax.c2p(-4, 1.5)

        dot = Dot(point)
        line = ax.get_horizontal_line(point, line_func=Line)

        self.add(ax, line, dot)
Parameters
  • point (Sequence[float]) – The point to which the horizontal line will be drawn.

  • kwargs – Additional parameters to be passed to get_line_from_axis_to_point

Returns

A horizontal line from the y-axis to the point.

Return type

Line

get_implicit_curve(func, min_depth=5, max_quads=1500, **kwargs)[source]

Creates the curves of an implicit function.

Parameters
  • func (Callable) – The function to graph, in the form of f(x, y) = 0.

  • min_depth (int) – The minimum depth of the function to calculate.

  • max_quads (int) – The maximum number of quads to use.

  • kwargs – Additional parameters to pass into ImplicitFunction

Return type

manim.mobject.functions.ImplicitFunction

Examples

Example: ImplicitExample

../_images/ImplicitExample-1.png
from manim import *

class ImplicitExample(Scene):
    def construct(self):
        ax = Axes()
        a = ax.get_implicit_curve(
            lambda x, y: y * (x - y) ** 2 - 4 * x - 8, color=BLUE
        )
        self.add(ax, a)
get_line_from_axis_to_point(index, point, line_func=<class 'manim.mobject.geometry.DashedLine'>, line_config=None, color='#BBBBBB', stroke_width=2)[source]

Returns a straight line from a given axis to a point in the scene.

Parameters
  • index (int) – Specifies the axis from which to draw the line. 0 = x_axis, 1 = y_axis

  • point (Sequence[float]) – The point to which the line will be drawn.

  • line_func (manim.mobject.geometry.Line) – The function of the Line mobject used to construct the line.

  • line_config (Optional[Dict]) – Optional arguments to passed to line_func.

  • color (colour.Color) – The color of the line.

  • stroke_width (float) – The stroke width of the line.

Returns

The line from an axis to a point.

Return type

Line

get_lines_to_point(point, **kwargs)[source]

Generate both horizontal and vertical lines from the axis to a point.

Examples

Example: GetLinesToPointExample

../_images/GetLinesToPointExample-1.png
from manim import *

class GetLinesToPointExample(Scene):
    def construct(self):
        ax = Axes()
        circ = Circle(radius=0.5).move_to([-4, -1.5, 0])

        lines_1 = ax.get_lines_to_point(circ.get_right(), color=GREEN_B)
        lines_2 = ax.get_lines_to_point(circ.get_corner(DL), color=BLUE_B)
        self.add(ax, lines_1, lines_2, circ)
Parameters
Returns

A VGroup of the horizontal and vertical lines.

Return type

VGroup

get_origin()[source]

Gets the origin of Axes.

Returns

The center point.

Return type

np.ndarray

get_riemann_rectangles(graph, x_range=None, dx=0.1, input_sample_type='left', stroke_width=1, stroke_color='#000000', fill_opacity=1, color=array(['#58C4DD', '#83C167'], dtype='<U7'), show_signed_area=True, bounded_graph=None, blend=False, width_scale_factor=1.001)[source]

Generates a VGroup of the Riemann Rectangles for a given curve.

Examples

Example: GetRiemannRectanglesExample

../_images/GetRiemannRectanglesExample-1.png
from manim import *

class GetRiemannRectanglesExample(Scene):
    def construct(self):
        ax = Axes(y_range=[-2, 10])
        quadratic = ax.get_graph(lambda x: 0.5 * x ** 2 - 0.5)

        # the rectangles are constructed from their top right corner.
        # passing an iterable to `color` produces a gradient
        rects_right = ax.get_riemann_rectangles(
            quadratic,
            x_range=[-4, -3],
            dx=0.25,
            color=(TEAL, BLUE_B, DARK_BLUE),
            input_sample_type="right",
        )

        # the colour of rectangles below the x-axis is inverted
        # due to show_signed_area
        rects_left = ax.get_riemann_rectangles(
            quadratic, x_range=[-1.5, 1.5], dx=0.15, color=YELLOW
        )

        bounding_line = ax.get_graph(
            lambda x: 1.5 * x, color=BLUE_B, x_range=[3.3, 6]
        )
        bounded_rects = ax.get_riemann_rectangles(
            bounding_line,
            bounded_graph=quadratic,
            dx=0.15,
            x_range=[4, 5],
            show_signed_area=False,
            color=(MAROON_A, RED_B, PURPLE_D),
        )

        self.add(
            ax, bounding_line, quadratic, rects_right, rects_left, bounded_rects
        )
Parameters
  • graph (manim.mobject.functions.ParametricFunction) – The graph whose area will be approximated by Riemann rectangles.

  • x_range (Optional[Sequence[float]]) – The minimum and maximum x-values of the rectangles. x_range = [x_min, x_max].

  • dx (Optional[float]) – The change in x-value that separates each rectangle.

  • input_sample_type (str) – Can be any of "left", "right" or "center". Refers to where the sample point for the height of each Riemann Rectangle will be inside the segments of the partition.

  • stroke_width (float) – The stroke_width of the border of the rectangles.

  • stroke_color (colour.Color) – The color of the border of the rectangle.

  • fill_opacity (float) – The opacity of the rectangles.

  • color (Union[Iterable[colour.Color], colour.Color]) – The colors of the rectangles. Creates a balanced gradient if multiple colors are passed.

  • show_signed_area (bool) – Indicates negative area when the curve dips below the x-axis by inverting its color.

  • blend (bool) – Sets the stroke_color to fill_color, blending the rectangles without clear separation.

  • bounded_graph (Optional[manim.mobject.functions.ParametricFunction]) – If a secondary graph is specified, encloses the area between the two curves.

  • width_scale_factor (float) – The factor by which the width of the rectangles is scaled.

Returns

A VGroup containing the Riemann Rectangles.

Return type

VGroup

get_secant_slope_group(x, graph, dx=None, dx_line_color='#FFFF00', dy_line_color=None, dx_label=None, dy_label=None, include_secant_line=True, secant_line_color='#83C167', secant_line_length=10)[source]
Creates two lines representing dx and df, the labels for dx and df, and

the secant to the curve at a particular x-value.

Examples

Example: GetSecantSlopeGroupExample

../_images/GetSecantSlopeGroupExample-1.png
from manim import *

class GetSecantSlopeGroupExample(Scene):
    def construct(self):
        ax = Axes(y_range=[-1, 7])
        graph = ax.get_graph(lambda x: 1 / 4 * x ** 2, color=BLUE)
        slopes = ax.get_secant_slope_group(
            x=2.0,
            graph=graph,
            dx=1.0,
            dx_label=Tex("dx = 1.0"),
            dy_label="dy",
            dx_line_color=GREEN_B,
            secant_line_length=4,
            secant_line_color=RED_D,
        )

        self.add(ax, graph, slopes)
Parameters
  • x (float) – The x-value at which the secant intersects the graph for the first time.

  • graph (manim.mobject.functions.ParametricFunction) – The curve for which the secant will be found.

  • dx (Optional[float]) – The change in x after which the secant exits.

  • dx_line_color (colour.Color) – The color of the line that indicates the change in x.

  • dy_line_color (Optional[colour.Color]) – The color of the line that indicates the change in y. Defaults to the color of graph.

  • dx_label (Optional[Union[float, str]]) – The label for the dx line. Defaults to MathTex for str and float inputs.

  • dy_label (Optional[Union[float, str]]) – The label for the dy line. Defaults to MathTex for str and float inputs.

  • include_secant_line (bool) – Whether to include the secant line in the graph, or just the df/dx lines and labels.

  • secant_line_color (colour.Color) – The color of the secant line.

  • secant_line_length (float) – The length of the secant line.

Returns

A group containing the elements: dx_line, df_line, and if applicable also dx_label, df_label, secant_line.

Return type

VGroup

get_vertical_line(point, **kwargs)[source]

A vertical line from the x-axis to a given point in the scene.

Examples

Example: GetVerticalLineExample

../_images/GetVerticalLineExample-1.png
from manim import *

class GetVerticalLineExample(Scene):
    def construct(self):
        ax = Axes().add_coordinates()
        point = ax.coords_to_point(-3.5, 2)

        dot = Dot(point)
        line = ax.get_vertical_line(point, line_config={"dashed_ratio": 0.85})

        self.add(ax, line, dot)
Parameters
  • point (Sequence[float]) – The point to which the vertical line will be drawn.

  • kwargs – Additional parameters to be passed to get_line_from_axis_to_point

Returns

A vertical line from the x-axis to the point.

Return type

Line

get_vertical_lines_to_graph(graph, x_range=None, num_lines=20, **kwargs)[source]

Obtains multiple lines from the x-axis to the curve.

Examples

Example: GetVerticalLinesToGraph

../_images/GetVerticalLinesToGraph-1.png
from manim import *

class GetVerticalLinesToGraph(Scene):
    def construct(self):
        ax = Axes(
            x_range=[0, 8.0, 1],
            y_range=[-1, 1, 0.2],
            axis_config={"number_scale_value": 0.5},
        ).add_coordinates()

        curve = ax.get_graph(lambda x: np.sin(x) / np.e ** 2 * x)

        lines = ax.get_vertical_lines_to_graph(
            curve, x_range=[0, 4], num_lines=30, color=BLUE
        )

        self.add(ax, curve, lines)
Parameters
  • graph (manim.mobject.functions.ParametricFunction) – The graph along which the lines are placed.

  • x_range (Optional[Sequence[float]]) – A list containing the lower and and upper bounds of the lines: x_range = [x_min, x_max].

  • num_lines (int) – The number of evenly spaced lines.

  • kwargs – Additional arguments to be passed to get_vertical_line()

Returns

The VGroup of the evenly spaced lines.

Return type

VGroup

get_x_axis_label(label, edge=array([1., 1., 0.]), direction=array([1., 1., 0.]), buff=0.1, **kwargs)[source]

Generate an x-axis label.

Examples

Example: GetXAxisLabelExample

../_images/GetXAxisLabelExample-1.png
from manim import *

class GetXAxisLabelExample(Scene):
    def construct(self):
        ax = Axes(x_range=(0, 8), y_range=(0, 5), x_length=8, y_length=5)
        x_label = ax.get_x_axis_label(
            Tex("$x$-values").scale(0.65), edge=DOWN, direction=DOWN, buff=0.5
        )
        self.add(ax, x_label)
Parameters
  • label (Union[float, str, manim.mobject.mobject.Mobject]) – The label. Defaults to MathTex for str and float inputs.

  • edge (Sequence[float]) – The edge of the x-axis to which the label will be added, by default UR.

  • direction (Sequence[float]) – Allows for further positioning of the label from an edge, by default UR.

  • buff (float) – The distance of the label from the line.

Returns

The positioned label.

Return type

Mobject

get_y_axis_label(label, edge=array([1., 1., 0.]), direction=array([1., 0.5, 0.]), buff=0.1, **kwargs)[source]

Generate a y-axis label.

Examples

Example: GetYAxisLabelExample

../_images/GetYAxisLabelExample-1.png
from manim import *

class GetYAxisLabelExample(Scene):
    def construct(self):
        ax = Axes(x_range=(0, 8), y_range=(0, 5), x_length=8, y_length=5)
        y_label = ax.get_y_axis_label(
            Tex("$y$-values").scale(0.65).rotate(90 * DEGREES),
            edge=LEFT,
            direction=LEFT,
            buff=0.3,
        )
        self.add(ax, y_label)
Parameters
  • label (Union[float, str, manim.mobject.mobject.Mobject]) – The label. Defaults to MathTex for str and float inputs.

  • edge (Sequence[float]) – The edge of the x-axis to which the label will be added, by default UR.

  • direction (Sequence[float]) – Allows for further positioning of the label from an edge, by default UR

  • buff (float) – The distance of the label from the line.

Returns

The positioned label.

Return type

Mobject

i2gp(x, graph)[source]

Alias for input_to_graph_point().

Parameters
Return type

numpy.ndarray

input_to_graph_point(x, graph)[source]

Returns the coordinates of the point on a graph corresponding to an x value.

Examples

Example: InputToGraphPointExample

../_images/InputToGraphPointExample-1.png
from manim import *

class InputToGraphPointExample(Scene):
    def construct(self):
        ax = Axes()
        curve = ax.get_graph(lambda x : np.cos(x))

        # move a square to PI on the cosine curve.
        position = ax.input_to_graph_point(x=PI, graph=curve)
        sq = Square(side_length=1, color=YELLOW).move_to(position)

        self.add(ax, curve, sq)
Parameters
Returns

The coordinates of the point on the graph corresponding to the x value.

Return type

np.ndarray

Raises

ValueError – When the target x is not in the range of the line graph.

p2c(point)[source]

Abbreviation for point_to_coords

slope_of_tangent(x, graph, **kwargs)[source]

Returns the slope of the tangent to the plotted curve at a particular x-value.

Examples

ax = Axes()
curve = ax.get_graph(lambda x: x ** 2)
ax.slope_of_tangent(x=-2, graph=curve)
# -3.5000000259052038
Parameters
Returns

The slope of the tangent with the x axis.

Return type

float