number_line

class janim.items.coordinate.number_line.NumberLine(x_range: RangeSpecifier = (-8, 8, 1), *, unit_size: int = 1, color: JAnimColor = '#BBBBBB', stroke_radius: float = 0.01, width: float | None = None, include_tip: bool = False, tip_config: dict = {}, include_ticks: bool = True, tick_size: float = 0.1, longer_tick_multiple: float = 1.5, numbers_with_elongated_ticks: Iterable[float] = [], include_numbers: bool = False, numbers_to_exclude: Iterable[float] = [], line_to_number_direction: ndarray = array([0., -1., 0.]), line_to_number_buff: float = 0.25, decimal_number_config: dict = {}, **kwargs)

数轴

tip_config_d = {'back_width': 0.25, 'body_length': 0.25}

箭头的默认属性

decimal_number_config_d = {'font_size': 16, 'num_decimal_places': 0}

数字的默认属性

property tip: ArrowTip | None
property ticks: Group[Line] | None
property numbers: Group[Text] | None
get_unit_size() float
get_tick_range() ndarray
add_ticks(excluding: Iterable[float] | None = None) Group[Line]
get_tick(x: float, size: float | None = None) Line
add_numbers(x_values: Iterable[float] | None = None, excluding: Iterable[float] | None = None, font_size: int = 24, **kwargs) Group[Text]
get_number_item(x: float, direction: ndarray | None = None, buff: float | None = None, **number_config) Text
cmpt_init_datas = {'color': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'depth': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.item.Item'>), 'fill': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'glow': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'points': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.points.Points'>), 'radius': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'stroke': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>)}
number_to_point(number: float | Iterable[float] | ndarray) ndarray

传入数值得到在坐标轴上对应的位置

传入的可以是:

  • 单个数,得到单个坐标,表示这个数在坐标轴上的位置; 例如 n2p(2) 得到 2 在坐标轴上的位置

  • 多个数,得到一组坐标,分别表示这些数在坐标轴上的位置; 例如 n2p([0, 2, 4]) 分别得到 0、2、4 在坐标轴上的位置

point_to_number(point: ndarray) float

传入坐标将其映射到坐标轴上,返回在坐标轴上的数值

n2p(number: float) ndarray

number_to_point 的缩写

p2n(point: ndarray) float

point_to_number 的缩写

class janim.items.coordinate.number_line.UnitInterval(x_range: RangeSpecifier = (0, 1, 0.1), *, unit_size: int = 10, numbers_with_elongated_ticks: Iterable[float] = [0, 1], decimal_number_config: dict = {'num_decimal_places': 1}, **kwargs)
cmpt_init_datas = {'color': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'depth': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.item.Item'>), 'fill': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'glow': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'points': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.points.Points'>), 'radius': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>), 'stroke': _ItemMeta._CmptInitData(info=<janim.components.component.CmptInfo object>, decl_cls=<class 'janim.items.vitem.VItem'>)}