A community-maintained Python framework for creating mathematical animations.
Fixed docs for :meth:`.Coordinate_system.add_coordinates` and moved :class: `~.Code` example (#1852)
Laith Bahodi3bd5672cccaf
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.pyindex 8412517b9..aa505e70a 100644--- a/manim/mobject/coordinate_systems.py+++ b/manim/mobject/coordinate_systems.py@@ -281,9 +281,12 @@ class CoordinateSystem:Optional[Iterable[float]], Union[Dict[float, Union[str, float, "Mobject"]]]],**kwargs,- ) -> VGroup:+ ):"""Adds labels to the axes.+ Parameters+ ----------+axes_numbersThe numbers to be added to the axes. Use ``None`` to represent an axis with default labels.@@ -298,7 +301,7 @@ class CoordinateSystem:ax.add_coordinates(x_labels, None, z_labels) # default y labels, custom x & z labelsax.add_coordinates(x_labels) # only x labels- ..code-block:: python+ .. code-block:: python# specifically control the position and value of the labels using a dictax = Axes(x_range=[0, 7])@@ -308,11 +311,6 @@ class CoordinateSystem:x_vals = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]x_dict = dict(zip(x_pos, x_vals))ax.add_coordinates(x_dict)-- Returns- -------- VGroup- A :class:`VGroup` of the number mobjects."""self.coordinate_labels = VGroup()diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.pyindex 7acbb5794..504ebb307 100644--- a/manim/mobject/svg/code_mobject.py+++ b/manim/mobject/svg/code_mobject.py@@ -46,6 +46,43 @@ class Code(VGroup):`weird <https://github.com/3b1b/manim/issues/1067>`_. Consider using:meth:`remove_invisible_chars` to resolve this issue.+ Examples+ --------++ Normal usage::++ listing = Code(+ "helloworldcpp.cpp",+ tab_width=4,+ background_stroke_width=1,+ background_stroke_color=WHITE,+ insert_line_no=True,+ style=Code.styles_list[15],+ background="window",+ language="cpp",+ )++ We can also render code passed as a string (but note that+ the language has to be specified in this case):++ .. manim:: CodeFromString+ :save_last_frame:++ class CodeFromString(Scene):+ def construct(self):+ code = '''from manim import Scene, Square++ class FadeInSquare(Scene):+ def construct(self):+ s = Square()+ self.play(FadeIn(s))+ self.play(s.animate.scale(2))+ self.wait()+ '''+ rendered_code = Code(code=code, tab_width=4, background="window",+ language="Python", font="Monospace")+ self.add(rendered_code)+Parameters----------file_name : :class:`str`@@ -101,42 +138,6 @@ class Code(VGroup):code : :class:`~.Paragraph`The highlighted code.- Examples- --------- Normal usage::-- listing = Code(- "helloworldcpp.cpp",- tab_width=4,- background_stroke_width=1,- background_stroke_color=WHITE,- insert_line_no=True,- style=Code.styles_list[15],- background="window",- language="cpp",- )-- We can also render code passed as a string (but note that- the language has to be specified in this case):-- .. manim:: CodeFromString- :save_last_frame:-- class CodeFromString(Scene):- def construct(self):- code = '''from manim import Scene, Square-- class FadeInSquare(Scene):- def construct(self):- s = Square()- self.play(FadeIn(s))- self.play(s.animate.scale(2))- self.wait()- '''- rendered_code = Code(code=code, tab_width=4, background="window",- language="Python", font="Monospace")- self.add(rendered_code)-"""# tuples in the form (name, aliases, filetypes, mimetypes)