A community-maintained Python framework for creating mathematical animations.
Improve Axes: rotate labels of y-axis (#718)
Roopesh7027f0a2e537
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.pyindex 196db4f12..6628f4936 100644--- a/manim/mobject/coordinate_systems.py+++ b/manim/mobject/coordinate_systems.py@@ -134,7 +134,7 @@ class Axes(VGroup, CoordinateSystem):self,axis_config=None,x_axis_config=None,- y_axis_config={"label_direction": LEFT},+ y_axis_config=None,center_point=ORIGIN,**kwargs):@@ -144,6 +144,8 @@ class Axes(VGroup, CoordinateSystem):"include_tip": True,"exclude_zero_from_default_numbers": True,}+ if y_axis_config is None:+ y_axis_config = {"label_direction": LEFT, "rotation": 90 * DEGREES}self.axis_config = axis_configif x_axis_config is None:x_axis_config = {}@@ -154,7 +156,6 @@ class Axes(VGroup, CoordinateSystem):VGroup.__init__(self, **kwargs)self.x_axis = self.create_axis(self.x_min, self.x_max, self.x_axis_config)self.y_axis = self.create_axis(self.y_min, self.y_max, self.y_axis_config)- self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)# Add as a separate group in case various other# mobjects are added to self, as for example in# NumberPlane belowdiff --git a/manim/mobject/number_line.py b/manim/mobject/number_line.pyindex c382b8883..ed02b9bfb 100644--- a/manim/mobject/number_line.py+++ b/manim/mobject/number_line.py@@ -24,6 +24,7 @@ class NumberLine(Line):color=LIGHT_GREY,unit_size=1,width=None,+ rotation=0,include_ticks=True,tick_size=0.1,tick_frequency=1,@@ -53,6 +54,7 @@ class NumberLine(Line):self.unit_size = unit_sizeself.include_ticks = include_ticksself.tick_size = tick_size+ self.rotation = rotationself.tick_frequency = tick_frequencyself.leftmost_tick = leftmost_tickself.numbers_with_elongated_ticks = numbers_with_elongated_ticks@@ -92,6 +94,7 @@ class NumberLine(Line):self.add_tip()if self.include_ticks:self.add_tick_marks()+ self.rotate(self.rotation)if self.include_numbers:self.add_numbers()@@ -186,7 +189,12 @@ class NumberLine(Line):return numbersdef get_number_mobject(- self, number, number_config=None, scale_val=None, direction=None, buff=None+ self,+ number,+ number_config=None,+ scale_val=None,+ direction=None,+ buff=None,):number_config = merge_dicts_recursively(self.decimal_number_config,diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.pyindex 149e51f24..84483e8db 100644--- a/manim/scene/graph_scene.py+++ b/manim/scene/graph_scene.py@@ -104,8 +104,8 @@ class GraphScene(Scene):y_axis_visibility=True, # show or hide the y axisx_label_position=UP + RIGHT, # where to place the label of the x axisy_label_position=UP + RIGHT, # where to place the label of the y axis- x_axis_config={},- y_axis_config={},+ x_axis_config=None,+ y_axis_config=None,**kwargs,):self.x_min = x_min@@ -135,8 +135,8 @@ class GraphScene(Scene):self.y_axis_visibility = y_axis_visibilityself.x_label_position = x_label_positionself.y_label_position = y_label_position- self.x_axis_config = x_axis_config- self.y_axis_config = y_axis_config+ self.x_axis_config = {} if x_axis_config is None else x_axis_config+ self.y_axis_config = {} if y_axis_config is None else y_axis_configsuper().__init__(**kwargs)def setup(self):@@ -232,6 +232,7 @@ class GraphScene(Scene):)y_axis.shift(self.graph_origin - y_shift)y_axis.rotate(np.pi / 2, about_point=self.graph_origin)+if len(self.y_labeled_nums) > 0:if self.exclude_zero_label:self.y_labeled_nums = [y for y in self.y_labeled_nums if y != 0]