如何用箭头绘制数轴
How to draw a number axis with arrow
我需要画一个横轴来表示数字,目前有一个NumberLine可以工作,但是没有箭头表示正方向。
是否有内置对象可以做到这一点?或者用代码手动创建这样的 class?
如果您对某个对象的工作原理有疑问,可以在源代码中查找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,
}
我需要画一个横轴来表示数字,目前有一个NumberLine可以工作,但是没有箭头表示正方向。
是否有内置对象可以做到这一点?或者用代码手动创建这样的 class?
如果您对某个对象的工作原理有疑问,可以在源代码中查找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,
}