A community-maintained Python framework for creating mathematical animations.
Add x_axis_config and y_axis_config CONFIG options
Jeff Smith72197a26a980
diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.pyindex 0b34384e5..6cf79b608 100644--- a/manim/scene/graph_scene.py+++ b/manim/scene/graph_scene.py@@ -61,6 +61,8 @@ class GraphScene(Scene):"x_add_end": 0, # extend the x axis to the right"y_add_start": 0, # extend the y axis to the bottom"y_add_end": 0, # extend the y axis to the top+ "x_axis_config": {},+ "y_axis_config": {}}def setup(self):@@ -91,17 +93,24 @@ class GraphScene(Scene):self.x_labeled_nums = []if self.x_leftmost_tick is None:self.x_leftmost_tick = self.x_min++ # The dictionary we update here are sensible defaults+ # that can be overridden through x_axis_config+ self.x_axis_config = dict({+ "x_min": self.x_min,+ "x_max": self.x_max,+ "unit_size": self.space_unit_to_x,+ "tick_frequency": self.x_tick_frequency,+ "leftmost_tick": self.x_leftmost_tick,+ "numbers_with_elongated_ticks": self.x_labeled_nums,+ "color": self.axes_color,+ "include_tip": self.include_tip,+ "add_start": self.x_add_start,+ "add_end": self.x_add_end+ }, **self.x_axis_config)+x_axis = NumberLine(- x_min=self.x_min,- x_max=self.x_max,- unit_size=self.space_unit_to_x,- tick_frequency=self.x_tick_frequency,- leftmost_tick=self.x_leftmost_tick,- numbers_with_elongated_ticks=self.x_labeled_nums,- color=self.axes_color,- include_tip=self.include_tip,- add_start=self.x_add_start,- add_end=self.x_add_end,+ **self.x_axis_config)x_axis.shift(self.graph_origin - x_axis.number_to_point(0))if len(self.x_labeled_nums) > 0:@@ -126,19 +135,26 @@ class GraphScene(Scene):self.y_labeled_nums = []if self.y_bottom_tick is None:self.y_bottom_tick = self.y_min++ # The dictionary we update here are sensible defaults+ # that can be overridden through y_axis_config+ self.y_axis_config = dict({+ "x_min": self.y_min,+ "x_max": self.y_max,+ "unit_size": self.space_unit_to_y,+ "tick_frequency": self.y_tick_frequency,+ "leftmost_tick": self.y_bottom_tick,+ "numbers_with_elongated_ticks": self.y_labeled_nums,+ "color": self.axes_color,+ "line_to_number_vect": LEFT,+ "label_direction": LEFT,+ "include_tip": self.include_tip,+ "add_start": self.y_add_start,+ "add_end": self.y_add_end+ }, **self.y_axis_config)+y_axis = NumberLine(- x_min=self.y_min,- x_max=self.y_max,- unit_size=self.space_unit_to_y,- tick_frequency=self.y_tick_frequency,- leftmost_tick=self.y_bottom_tick,- numbers_with_elongated_ticks=self.y_labeled_nums,- color=self.axes_color,- line_to_number_vect=LEFT,- label_direction=LEFT,- include_tip=self.include_tip,- add_start=self.y_add_start,- add_end=self.y_add_end,+ **self.y_axis_config)y_axis.shift(self.graph_origin - y_axis.number_to_point(0))y_axis.rotate(np.pi / 2, about_point=y_axis.number_to_point(0))