A community-maintained Python framework for creating mathematical animations.
Fix axes plotting bug with logarithmic x-axis (#2548)
Simon Ellmannac1ee9a683ce
diff --git a/manim/mobject/functions.py b/manim/mobject/functions.pyindex afc21d327..60c450703 100644--- a/manim/mobject/functions.py+++ b/manim/mobject/functions.py@@ -143,7 +143,10 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):for t1, t2 in zip(boundary_times[0::2], boundary_times[1::2]):t_range = np.array(- [*self.scaling.function(np.arange(t1, t2, self.t_step)), t2],+ [+ *self.scaling.function(np.arange(t1, t2, self.t_step)),+ self.scaling.function(t2),+ ],)points = np.array([self.function(t) for t in t_range])self.start_new_path(points[0])diff --git a/tests/test_graphical_units/control_data/coordinate_system/plot_log_x_axis.npz b/tests/test_graphical_units/control_data/coordinate_system/plot_log_x_axis.npznew file mode 100644index 000000000..f215752d0Binary files /dev/null and b/tests/test_graphical_units/control_data/coordinate_system/plot_log_x_axis.npz differdiff --git a/tests/test_graphical_units/test_coordinate_systems.py b/tests/test_graphical_units/test_coordinate_systems.pyindex 685ffe1e1..c61a9a53b 100644--- a/tests/test_graphical_units/test_coordinate_systems.py+++ b/tests/test_graphical_units/test_coordinate_systems.py@@ -44,6 +44,19 @@ def test_implicit_graph(scene):scene.add(ax, graph)+@frames_comparison+def test_plot_log_x_axis(scene):+ ax = Axes(+ x_range=[-1, 4],+ y_range=[0, 3],+ x_axis_config={"scaling": LogBase()},+ )++ graph = ax.plot(lambda x: 2 if x < 10 else 1, x_range=[-1, 4])++ scene.add(ax, graph)++@frames_comparisondef test_number_plane_log(scene):"""Test that NumberPlane generates its lines properly with a LogBase"""