Repository: ManimCommunity/manim
File: manim/mobject/graphing/coordinate_systems.py (Python)

Code before:

    # graphing

    def plot(
        self,
        function: Callable[[float], float],
        x_range: Sequence[float] | None = None,
        use_vectorized: bool = False,
        colorscale: Union[Iterable[Color], Color] | None = None,
        colorscale_axis: int = 1,
        **kwargs,
    ):
        """Generates a curve based on a function.

        Parameters
        ----------
        function
            The function used to construct the :class:`~.ParametricFunction`.
        x_range
            The range of the curve along the axes. ``x_range = [x_min, x_max, x_step]``.
        use_vectorized
            Whether to pass in the generated t value array to the function. Only use this if your function supports it.
            Output should be a numpy array of shape ``[y_0, y_1, ...]``
        colorscale
            Colors of the function. Optional parameter used when coloring a function by values. Passing a list of colors
            and a colorscale_axes will color the function by y-value. Passing a list of tuples in the form ``(color, pivot)``
            allows user-defined pivots where the color transitions.
        colorscale_axis
            Defines the axis on which the colorscale is applied (0 = x, 1 = y), default is y-axis (1).
        kwargs
            Additional parameters to be passed to :class:`~.ParametricFunction`.

        Returns
        -------
        :class:`~.ParametricFunction`
            The plotted curve.


        .. 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
        --------
        .. manim:: PlotExample
            :save_last_frame:

            class PlotExample(Scene):
                def construct(self):
                    # construct the axes

Review comment (suggestion):
```suggestion
            and a colorscale_axis will color the function by y-value. Passing a list of tuples in the form ``(color, pivot)``
```

Code after:
    def get_lines_to_point(self, point: Sequence[float], **kwargs) -> VGroup:
        """Generate both horizontal and vertical lines from the axis to a point.

        Parameters
        ----------
        point
            A point on the scene.
        kwargs
            Additional parameters to be passed to :meth:`get_line_from_axis_to_point`

        Returns
        -------
        :class:`~.VGroup`
            A :class:`~.VGroup` of the horizontal and vertical lines.


        .. seealso::
            :meth:`~.CoordinateSystem.get_vertical_line`
            :meth:`~.CoordinateSystem.get_horizontal_line`

        Examples
        --------
        .. manim:: GetLinesToPointExample
            :save_last_frame:

            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)
        """

        return VGroup(
            self.get_horizontal_line(point, **kwargs),
            self.get_vertical_line(point, **kwargs),
        )

    # graphing

    def plot(
        self,
        function: Callable[[float], float],
        x_range: Sequence[float] | None = None,
        use_vectorized: bool = False,
        colorscale: Union[Iterable[Color], Iterable[Color, float]] | None = None,
        colorscale_axis: int = 1,
        **kwargs: Any,
    ) -> ParametricFunction: