3b1b / manim

Animation engine for explanatory math videos
MIT License
71.28k stars 6.26k forks source link

Graphs not rendering properly #1522

Open matiaspalumbo opened 3 years ago

matiaspalumbo commented 3 years ago

Hello, I've been recently trying out on Manimgl the code from example_scenes.py, and I've encountered that some graphs don't show up properly in the render. More concretely, there are patches of the curves that seem to be "skipped", or not rendered properly (particularly on the sine and parabolic graphs). I was't able to fix this. Below is the code and a screen recording of the graphs and the scene in question.

https://user-images.githubusercontent.com/64146682/119419163-06e7b500-bcd0-11eb-85d2-e7ae204ef5bc.mov

class GraphExample(Scene):
    def construct(self):
        self.wait(10)
        axes = Axes((-3, 10), (-1, 8))
        axes.add_coordinate_labels()
        self.play(Write(axes, lag_ratio=0.01, run_time=1))
        sin_graph = axes.get_graph(
            lambda x: 2 * math.sin(x),
            color=BLUE,
        )
        relu_graph = axes.get_graph(
            lambda x: max(x, 0),
            use_smoothing=False,
            color=YELLOW,
        )
        step_graph = axes.get_graph(
            lambda x: 2.0 if x > 3 else 1.0,
            discontinuities=[3],
            color=GREEN,
        )
        sin_label = axes.get_graph_label(sin_graph, "\\sin(x)")
        relu_label = axes.get_graph_label(relu_graph, Text("ReLU"))
        step_label = axes.get_graph_label(step_graph, Text("Step"), x=4)
        self.play(
            ShowCreation(sin_graph),
            FadeIn(sin_label, RIGHT),
        )
        self.wait(2)
        self.play(
            ReplacementTransform(sin_graph, relu_graph),
            FadeTransform(sin_label, relu_label),
        )
        self.wait()
        self.play(
            ReplacementTransform(relu_graph, step_graph),
            FadeTransform(relu_label, step_label),
        )
        self.wait()

        parabola = axes.get_graph(lambda x: 0.25 * x**2)
        parabola.set_stroke(BLUE)
        self.play(
            FadeOut(step_graph),
            FadeOut(step_label),
            ShowCreation(parabola)
        )
        self.wait()
        dot = Dot(color=RED)
        dot.move_to(axes.i2gp(2, parabola))
        self.play(FadeIn(dot, scale=0.5))

        x_tracker = ValueTracker(2)
        f_always(
            dot.move_to,
            lambda: axes.i2gp(x_tracker.get_value(), parabola)
        )

        self.play(x_tracker.animate.set_value(4), run_time=3)
        self.play(x_tracker.animate.set_value(-2), run_time=3)
        self.wait()
Leoriem-code commented 3 years ago

I tried the code and I have no problem. Does the issue still exist with the most recent version of manimgl ?

Benarl commented 2 years ago

Hello, it happens the same to me with the last version of manim v1.3.0, I simply run the example_scenes.py on UpdatersExample and i get lots of lags on the text and on the bracket.

Edit : config = python 3.10.1, Windows 10 64bits,

https://user-images.githubusercontent.com/23723883/147282218-6a199f9d-ba4a-4541-85d5-4271d1e6d335.mp4

Ray625625 commented 2 months ago

Hello, it happens the same to me with the last version of manim v1.3.0, I simply run the example_scenes.py on UpdatersExample and i get lots of lags on the text and on the bracket.

Edit : config = python 3.10.1, Windows 10 64bits, UpdatersExample.mp4

Hi, did you figure out how to fix that? @Benarl