Repository: ManimCommunity/manim
Pull request: Implemented :meth:`.CoordinateSystem.input_to_graph_coords` and fixed :meth:`.CoordinateSystem.angle_of_tangent`
<!-- Thank you for contributing to Manim! Learn more about the process in our contributing guidelines: https://docs.manim.community/en/latest/contributing.html -->

## Overview: What does this pull request change?
<!-- If there is more information than the PR title that should be added to our release changelog, add it in the following changelog section. This is optional, but recommended for larger pull requests. -->
<!--changelog-start-->

<!--changelog-end-->
Fixes #2023 and #1701 
## Motivation and Explanation: Why and how do your changes improve the library?
<!-- Optional for bugfixes, small enhancements, and documentation-related PRs. Otherwise, please give a short reasoning for your changes. -->
Before:
```py
>>> from manim import *
Manim Community v0.10.0

>>> ax = Axes([-2.5, 2.5], [-1, 5], x_length=10, y_length=6)
>>> graph = ax.get_graph(lambda x: x ** 2, x_range=[-2.5,2.5,0.01])
>>> ax.angle_of_tangent(2, graph)
1.1071487177940904
>>> np.arctan(4)
1.3258176636680326
```
After:
```py
>>> from manim import *
Manim Community v0.9.0

>>> ax = Axes([-2.5, 2.5], [-1, 5], x_length=10, y_length=6)
>>> graph = ax.get_graph(lambda x: x ** 2, x_range=[-2.5,2.5,0.01])
>>> ax.angle_of_tangent(2, graph)
1.3258176636680326
>>> np.arctan(4)
1.3258176636680326
```
## Links to added or changed documentation pages
<!-- Please add links to the affected documentation pages (edit the description after opening the PR). The link to the documentation for your PR is https://manimce--####.org.readthedocs.build/en/####/, where #### represents the PR number. -->


## Further Information and Comments
<!-- If applicable, put further comments for the reviewers here. -->



<!-- Thank you again for contributing! Do not modify the lines below, they are for reviewers. -->
## Reviewer Checklist
- [ ] The PR title is descriptive enough for the changelog, and the PR is labeled correctly
- [ ] If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
- [ ] If applicable: newly added functions and classes are tested


Problem statement:
Typo in coordinate_systems
At `manim/mobject/coordinate_systems.py` line 195 and 196, the origin code is 

```python
    def get_y_unit_size(self):
        return self.get_x_axis().get_unit_size()
```

And it should be
```python
    def get_y_unit_size(self):
        return self.get_y_axis().get_unit_size()
```
This typo is small but may cause confusion if someone use this method. Please fix it soon.

Hints from issue discussion:

Commit message: Merge branch 'main' into coord-sys

Patch to review:
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
index c660d8d6bb..b605eef5d4 100644
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -814,6 +814,29 @@ def construct(self):
                     f"x={x} not located in the range of the graph ([{self.p2c(graph.get_start())[0]}, {self.p2c(graph.get_end())[0]}])",
                 )
 
+    def input_to_graph_coords(self, x: float, graph: "ParametricFunction") -> Tuple:
+        """
+        Returns a tuple of the axis relative coordinates of the point
+        on the graph based on the x-value given.
+
+        Examples
+        --------
+
+        .. code-block:: python
+
+            ax = Axes()
+            curve = ax.get_graph(lambda x: x ** 2)
+            ax.input_to_graph_coords(x=3, graph=curve)
+            # (3, 9)
+        """
+        return x, graph.underlying_function(x)
+
+    def i2gc(self, x: float, graph: "ParametricFunction") -> Tuple:
+        """
+        Alias for :meth:`input_to_graph_coords`.
+        """
+        return self.input_to_graph_coords(x, graph)
+
     def i2gp(self, x: float, graph: "ParametricFunction") -> np.ndarray:
         """
         Alias for :meth:`input_to_graph_point`.
@@ -1180,7 +1203,7 @@ def angle_of_tangent(
             ax = Axes()
             curve = ax.get_graph(lambda x: x ** 2)
             ax.angle_of_tangent(x=3, graph=curve)
-            # 1.3825747960950903
+            # 1.4056476493802699
 
 
         Parameters
@@ -1198,8 +1221,8 @@ def angle_of_tangent(
             The angle of the tangent to the curve.
         """
 
-        p0 = self.input_to_graph_point(x, graph)
-        p1 = self.input_to_graph_point(x + dx, graph)
+        p0 = np.array([*self.input_to_graph_coords(x, graph)])
+        p1 = np.array([*self.input_to_graph_coords(x + dx, graph)])
         return angle_of_vector(p1 - p0)
 
     def slope_of_tangent(


Code review comments:
diff_hunk: @@ -814,6 +814,29 @@ def construct(self):
                     f"x={x} not located in the range of the graph ([{self.p2c(graph.get_start())[0]}, {self.p2c(graph.get_end())[0]}])",
                 )
 
+    def input_to_graph_coords(self, x: float, graph: "ParametricFunction") -> Tuple:
+        """
+        Returns a tuple of the axis relative coordinates of the point
+        on the graph based on the x-value given.
+
+        Examples
+        --------
+
+        .. code-block:: python
+
+            ax = Axes()
+            curve = ax.get_graph(lambda x: x ** 2)
+            ax.input_to_graph_coords(x=3, graph=curve)
+            # (3, 9)
path: manim/mobject/coordinate_systems.py
text: @user1:
Let's turn this into a proper doctest to improve test coverage. Also `get_graph` -> `plot`.

```suggestion
            >>> from manim import Axes
            >>> ax = Axes()
            >>> parabola = ax.plot(lambda x: x ** 2)
            >>> ax.input_to_graph_coords(x=3, graph=parabola)
            (3, 9)
```