Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

graph_scene: correct placement of labels (#661)

Philipp Imhofe2759ad7efca
diff --git a/manim/scene/graph_scene.py b/manim/scene/graph_scene.py
index 2e5c3a629..dbd807268 100644
--- a/manim/scene/graph_scene.py
+++ b/manim/scene/graph_scene.py
@@ -117,11 +117,10 @@ class GraphScene(Scene):
if self.x_axis_label:
x_label = Tex(self.x_axis_label)
x_label.next_to(
- x_axis.get_tips() if self.include_tip else x_axis.get_tick_marks(),
+ x_axis.get_corner(self.x_label_position),
self.x_label_position,
buff=SMALL_BUFF,
)
- x_label.shift_onto_screen()
x_axis.add(x_label)
self.x_axis_label_mob = x_label
@@ -164,7 +163,6 @@ class GraphScene(Scene):
self.y_label_position,
buff=SMALL_BUFF,
)
- y_label.shift_onto_screen()
y_axis.add(y_label)
self.y_axis_label_mob = y_label
diff --git a/tests/control_data/graphical_units_data/graph/AxesTest.npz b/tests/control_data/graphical_units_data/graph/AxesTest.npz
new file mode 100644
index 000000000..51d28b7d6
Binary files /dev/null and b/tests/control_data/graphical_units_data/graph/AxesTest.npz differ
diff --git a/tests/control_data/graphical_units_data/graph/PlotFunctions.npz b/tests/control_data/graphical_units_data/graph/PlotFunctions.npz
index 2eb5a985f..dfddd05f2 100644
Binary files a/tests/control_data/graphical_units_data/graph/PlotFunctions.npz and b/tests/control_data/graphical_units_data/graph/PlotFunctions.npz differ
diff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.py
new file mode 100644
index 000000000..45a23e162
--- /dev/null
+++ b/tests/test_graphical_units/test_axes.py
@@ -0,0 +1,42 @@
+import pytest
+
+from manim import *
+from ..utils.testing_utils import get_scenes_to_test
+from ..utils.GraphicalUnitTester import GraphicalUnitTester
+
+
+class AxesTest(GraphScene):
+ CONFIG = {
+ "x_min": -5,
+ "x_max": 5,
+ "y_min": -3,
+ "y_max": 3,
+ "x_axis_config": {
+ "add_start": 0.5,
+ "add_end": 0.5,
+ "include_tip": True,
+ },
+ "y_axis_config": {
+ "add_start": 0.25,
+ "add_end": 0.5,
+ "include_tip": True,
+ },
+ "x_axis_visibility": True,
+ "y_axis_visibility": True,
+ "y_label_position": UP,
+ "x_label_position": RIGHT,
+ "graph_origin": ORIGIN,
+ "axes_color": WHITE,
+ }
+
+ def construct(self):
+ self.setup_axes(animate=True)
+
+
+MODULE_NAME = "graph"
+
+
[email protected]("scene_to_test", get_scenes_to_test(__name__), indirect=False)
+def test_scene(scene_to_test, tmpdir, show_diff):
+ GraphicalUnitTester(scene_to_test[1], MODULE_NAME, tmpdir).test(show_diff=show_diff)