본문 바로가기

Programming/Manim code

[032]Axes

반응형
axes = Axes()

 

 


class AxesTest(Scene):
    def construct(self):       
        self.c2p_test()

    def c2p_test(self):
        axes = Axes(
            x_min=-10, x_max=10,
            y_min=-100, y_max=100,

            number_line_config={
                "tick_size": 0.05,
            },

            x_axis_config={
                "unit_size": 0.5,
                "tick_frequency": 2,
                "include_numbers": True,
                "numbers_to_show": np.append(np.arange(-10,0,2),np.arange(2,10,2)),
            },
            y_axis_config={
                "unit_size": 6/200,
                "tick_frequency": 50,
                "include_numbers": True,
                "numbers_to_show": [-100,-50,50,100],
                "label_direction": UP,
            },
        )

        self.add(axes)
        self.wait()

        line = Line (axes.c2p(-8,-50), axes.c2p(4,50))
        self.play(ShowCreation(line))

 

 

 


    def get_graph_test(self):
        axes = Axes(
            x_min=0, x_max=8,
            y_min=-PI / 2, y_max=PI / 2,

            graph_style= {
               "stroke_color": GREEN,
               "stroke_width": 3,
               "fill_opacity": 0,
            },

            number_line_config={
                "color": "#EEEEEE",
                "stroke_width": 2,
                "include_tip": False,
            },

            y_axis_config={
                "tick_frequency": PI / 8,
                "unit_size": 1.5,
            },
        )

        axes.center().shift(LEFT)

        L = 2.0
        g = 20
        theta0 = 20 * DEGREES
        graph = axes.get_graph(
            lambda t: theta0 * np.cos(t * np.sqrt(g / L)),
            color=YELLOW,
        )

        self.add(axes,graph)
        self.wait()

 

반응형

'Programming > Manim code' 카테고리의 다른 글

[34]GraphScene  (0) 2020.05.12
[33]NumberPlane  (0) 2020.05.12
[031]NumberLine  (0) 2020.05.11
[030]FunctionGraph  (0) 2020.05.11
[029]ParametricFunction  (0) 2020.05.11