如何用箭头绘制数字轴

时间:2019-07-17 07:15:45

标签: manim

我需要画一条水平轴来描述数字,目前有一个NumberLine可以工作,但是没有箭头指示正方向。

是否存在内置对象?或使用代码手动创建此类?

1 个答案:

答案 0 :(得分:0)

如果对对象的工作方式有疑问,可以在源代码manimlib/mobject/中查找它 就您而言,它位于number_line.py中,代码并不难理解,因此避免了询问。

class NumberLineExample(Scene):
    def construct(self):
        nl=NumberLine(x_min=-2,
                       x_max=2,
                       include_numbers=True,
                       include_tip=True,
                       label_direction=UP
                      )

        self.add(nl)

如果您看到源代码,则会找到所有选项:

class NumberLine(Line):
    CONFIG = {
        "color": LIGHT_GREY,
        "x_min": -FRAME_X_RADIUS,
        "x_max": FRAME_X_RADIUS,
        "unit_size": 1,
        "include_ticks": True,
        "tick_size": 0.1,
        "tick_frequency": 1,
        # Defaults to value near x_min s.t. 0 is a tick
        # TODO, rename this
        "leftmost_tick": None,
        # Change name
        "numbers_with_elongated_ticks": [0],
        "include_numbers": False,
        "numbers_to_show": None,
        "longer_tick_multiple": 2,
        "number_at_center": 0,
        "number_scale_val": 0.75,
        "label_direction": DOWN,
        "line_to_number_buff": MED_SMALL_BUFF,
        "include_tip": False,
        "tip_width": 0.25,
        "tip_height": 0.25,
        "decimal_number_config": {
            "num_decimal_places": 0,
        },
        "exclude_zero_from_default_numbers": False,
    }