-2

` from manim import *

class ParabolaWithRiemannRectangles(Scene): def construct(self): # Create a coordinate system plane = NumberPlane( x_range=(-4, 4, 1), y_range=(-1, 9, 1), x_length=8, y_length=10, )

    # Define the parabola function
    def parabola(x):
        return x ** 2

    # Create the parabola graph
    parab_graph = plane.get_graph(parabola).set_color(GREEN)

    # Get Riemann rectangles for the parabola
    rectangles = plane.get_riemann_rectangles(
        parab_graph, x_range=(-4, 4), dx=0.5
    )

    # Add the coordinate system, parabola, and rectangles to the scene
    self.play(Create(plane))
    self.play(Create(parab_graph))
    self.play(Create(rectangles))
    self.wait()

` TypeError: getter() takes 1 positional argument but 2 were given

1 Answers1

0

from manim import * indicates that you are using ManimCE, the community edition of Manim. However the command .get_graph() has in this edition of Manim a long time ago been replaced by .plot()

Why are there different versions of Manim? Where can I find more resources for learning Manim?

from manim import *

class ParabolaWithRiemannRectangles(Scene): 
    def construct(self): 
        # Create a coordinate system 
        plane = NumberPlane( x_range=(-4, 4, 1), y_range=(-1, 9, 1), x_length=8, y_length=10, )

        # Define the parabola function
        def parabola(x):
            return x ** 2

        # Create the parabola graph
        parab_graph = plane.plot(parabola).set_color(GREEN)

        # Get Riemann rectangles for the parabola
        rectangles = plane.get_riemann_rectangles(
            parab_graph, x_range=(-4, 4), dx=0.5
        )

        # Add the coordinate system, parabola, and rectangles to the scene
        self.play(Create(plane))
        self.play(Create(parab_graph))
        self.play(Create(rectangles))
        self.wait()

rendered result

uwezi
  • 551
  • 2
  • 3