coordinate_systems¶
- class janim.items.coordinate.coordinate_systems.CoordinateSystem(*args, num_sampled_graph_points_per_tick, **kwargs)¶
Bases:
objectAbstract base class for coordinate systems
For concrete implementations, please refer to
Axes,ThreeDAxes, andNumberPlane- static create_axis(range: RangeSpecifier, axis_config: dict, length: float | None) NumberLine¶
- abstractmethod get_axes() list[NumberLine]¶
Get a list composed of
NumberLinein each direction
- get_origin() ndarray¶
- coords_to_point(*coords: float) ndarray¶
Pass coordinates to get the corresponding position
For example,
c2p(1, 3)gets the position (1,3)
- coords_array_to_points(coords_array: VectArray) ndarray¶
Pass a set of coordinates to get the corresponding set of positions
For example,
c2p([[1, 3], [2, 1], [-1, -1]])gets the corresponding three positions
- c2p(*coords: float) ndarray¶
Abbreviation for
coords_to_point()
- point_to_coords3d(point: Vect | Iterable[Vect]) ndarray¶
Pass a position to get the corresponding coordinates (but will be expanded to 3D coordinates; for 2D coordinate systems, the third component represents the distance from the 2D plane)
Can also pass a set of positions to get a corresponding set of coordinates
- p2c3d(point: Vect | Iterable[Vect]) ndarray¶
Abbreviation for
point_to_coords3d()
- point_to_coords(point: Vect | Iterable[Vect]) ndarray¶
Pass a position to get the corresponding coordinates
Can also pass a set of positions to get a corresponding set of coordinates
- p2c(point: Vect | Iterable[Vect]) ndarray¶
Abbreviation for
point_to_coords()
- number_to_point(number: complex | float) ndarray¶
Pass a complex number to get the corresponding position
- n2p(number: complex | float) ndarray¶
Abbreviation for
number_to_point()
- point_to_number(point: Vect) complex¶
Pass a position to get the corresponding complex number
- p2n(point: Vect) complex¶
Abbreviation for
point_to_number()
- class janim.items.coordinate.coordinate_systems.Axes(x_range: RangeSpecifier = (-8.0, 8.0, 1), y_range: RangeSpecifier = (-4.0, 4.0, 1), *, num_sampled_graph_points_per_tick: int = 5, axis_config: dict = {}, x_axis_config: dict = {}, y_axis_config: dict = {}, x_length: float | None = None, y_length: float | None = None, height: float | None = None, width: float | None = None, unit_size: float = 1.0, **kwargs)¶
Bases:
CoordinateSystem,MarkedItem,NamedGroupMixin2D Axes
num_sampled_graph_points_per_tick:Indicates the number of points sampled in each tick segment by the
get_graph()method when the sampling step is omittedaxis_config:Configuration shared by both x and y axes. For available parameters, please refer to
NumberLinex_axis_config:Configuration for the x-axis. For available parameters, please refer to
NumberLiney_axis_config:Configuration for the y-axis. For available parameters, please refer to
NumberLinex_length:When specified, stretches the length of the x-axis to match this value
y_length:When specified, stretches the length of the y-axis to match this value
unit_size:Specifies the unit length for x and y coordinates. Ignored if the corresponding
*_lengthis specifiedNote: To specify
unit_sizefor a specific axis, please pass it via the corresponding*_axis_config
- default_axis_config = {'numbers_to_exclude': [0]}¶
- default_x_axis_config = {}¶
- default_y_axis_config = {'line_to_number_direction': array([0., 1., 0.])}¶
- axis_config_d = {'numbers_to_exclude': [0]}¶
- x_axis_config_d = {}¶
- y_axis_config_d = {'line_to_number_direction': array([0., 1., 0.])}¶
- property x_axis: NumberLine¶
- property y_axis: NumberLine¶
- get_axes() list[NumberLine]¶
Get a list composed of
NumberLinein each direction
- get_graph(function: Callable[[float], float], x_range: RangeSpecifier | None = None, *, bind: bool = True, **kwargs) ParametricCurve¶
Constructs a function curve based on coordinate axes, using
ParametricCurvefunction: Function used to construct the curvex_range: Domain of the functionIf not specified, the domain of the x-axis is used
When specified,
[x_min, x_max, x_step]can be used, or the sampling step can be omitted as[x_min, x_max]If the sampling step is not specified, the axis tick step divided by the item’s
num_sampled_graph_points_per_tickis used as the sampling stepbind: By default isTrue, makes the function curve automatically synchronize with transformations applied to the coordinate system, can also synchronize animations. For details, seeNumberPlaneExamplein API Demonstration
Warning
When
bind=True, do not place the function curve and coordinate system in the sameGroupfor coordinate transformationsBecause it will cause the transformation effect to be applied twice (once by
Groupand once bybind=True)If you need to place them in the same
Group, passbind=Falseto avoid this situation
- get_parametric_curve(function: Callable[[float], Vect], t_range: tuple[float, float, float] = (0, 1, 0.1), *, bind: bool = True, **kwargs)¶
Constructs a parametric curve based on coordinate axes, i.e.,
ParametricCurvefunction: Parametric function that maps values to points on the coordinate systembind: By default isTrue, makes the parametric curve automatically synchronize with transformations applied to the coordinate system, can also synchronize animations. For details, seeNumberPlaneExamplein API Demonstration
Warning
When
bind=True, do not place the parametric curve and coordinate system in the sameGroupfor coordinate transformationsBecause it will cause the transformation effect to be applied twice (once by
Groupand once bybind=True)If you need to place them in the same
Group, passbind=Falseto avoid this situation
- get_area(graph: ParametricCurve, x_range: tuple[float, float] | None = None, color: JAnimColor = '#58C4DD', alpha: float = 0.3, stroke_alpha: float | None = None, fill_alpha: float | None = None, bounded_graph: ParametricCurve = None, **kwargs) Polygon¶
Constructs the region enclosed by
graphand the coordinate axes within thex_rangeinterval, represented usingPolygongraph: Function curve, see alsoget_graph()x_range: Minimum and maximum values of thexinterval,x_range = [x_min, x_max]bounded_graph: If this parameter is specified, the region enclosed bygraphandbounded_graphwill be constructed, rather than with the coordinate axes
- get_axis_labels(x_label: str | Points = 'x', y_label: str | Points = 'y', x_kwargs: dict = {}, y_kwargs: dict = {}, **kwargs) Group[TypstMath | Points]¶
For details, see
get_axis_label()If
ensure_on_screen=Trueis set, axis labels will automatically adjust their position to move within the default screen area
- get_x_axis_label(label: str | Points = 'x', **kwargs) TypstMath | Points¶
For details, see
get_axis_label()If
ensure_on_screen=Trueis set, axis labels will automatically adjust their position to move within the default screen area
- get_y_axis_label(label: str | Points = 'y', **kwargs) TypstMath | Points¶
For details, see
get_axis_label()If
ensure_on_screen=Trueis set, axis labels will automatically adjust their position to move within the default screen area
- class janim.items.coordinate.coordinate_systems.ThreeDAxes(x_range: RangeSpecifier = (-6, 6, 1), y_range: RangeSpecifier = (-5, 5, 1), z_range: RangeSpecifier = (-4, 4, 1), *, axis_config: dict = {}, z_length: float | None = None, z_axis_config: dict = {}, z_normal: Vect = array([0., 1., 0.]), **kwargs)¶
Bases:
Axes3D Axes
z_normalindicates the orientation of ticks and arrow-tip on the z-axis. Defaults to facingUP
For other available parameters, please refer to and draw analogies from
Axes- default_z_axis_config = {}¶
- z_axis_config_d = {}¶
- property z_axis: NumberLine¶
- get_axes() list[NumberLine]¶
Get a list composed of
NumberLinein each direction
- get_axis_labels(x_label: str | Points = 'x', y_label: str | Points = 'y', z_label: str | Points = 'z', x_kwargs: dict = {}, y_kwargs: dict = {}, z_kwargs: dict = {}, rotate_xy: bool = True, z_point_up: bool = True, **kwargs) Group[TypstMath | Points]¶
For details, see
get_axis_label()Additionally, by default
rotate_xy=Truerotates the x and y axis labels 180 degrees in place to match the perspective of looking at the origin from the positive directions of the x, y, and z axesFurthermore, directly generated z-axis labels are parallel to the 2D plane. By default
point_up=Trueorients them upright to align with the z-axis direction. Passpoint_up=Falseto disable this behavior
- get_z_axis_label(label: str | Points = 'z', point_up: bool = True, **kwargs) TypstMath | Points¶
For details, see
get_axis_label()Additionally, directly generated axis labels are parallel to the 2D plane. By default
point_up=Trueorients them upright to align with the z-axis direction. Passpoint_up=Falseto disable this behavior
- class janim.items.coordinate.coordinate_systems.CmptVPoints_NumberPlaneImpl(*args, **kwargs)¶
Bases:
Cmpt_VPoints- prepare_for_nonlinear_transform(num_inserted_curves: int = 50, *, root_only=False) Self¶
- class janim.items.coordinate.coordinate_systems.NumberPlane(x_range: RangeSpecifier = (-8.0, 8.0, 1), y_range: RangeSpecifier = (-4.0, 4.0, 1), background_line_style: dict = {}, faded_line_style: dict = {}, faded_line_ratio: int = 4, **kwargs)¶
Bases:
AxesCoordinate Grid
Generally includes:
Axes:
Defaults to white axes, without arrow tips and tick lines
Major grid lines
Default color is BLUE_D. Can be adjusted via
background_line_styleMinor grid lines:
Can be adjusted via
faded_line_styleWhen
faded_line_styleis not set, it adopts the same configuration asbackground_line_style, but with 50% opacityUse
faded_line_ratioto adjust the number of minor grid lines within each grid cellFor example, the default
4means 4 minor grid lines are evenly distributed between two major grid linesCan be set to
1to reduce density, or set to0to disable minor grid lines
For more parameters and methods, please refer to
Axes- points¶
- default_background_line_style = {'stroke_color': '#29ABCA', 'stroke_radius': 0.01}¶
- default_axis_config = {'include_ticks': False, 'include_tip': False, 'line_to_number_buff': 0.1, 'line_to_number_direction': array([-1., -1., 0.]), 'stroke_color': '#FFFFFF', 'stroke_radius': 0.01}¶
- default_y_axis_config = {'line_to_number_direction': array([-1., -1., 0.]), 'numbers_to_exclude': [0]}¶
- background_line_style_d = {'stroke_color': '#29ABCA', 'stroke_radius': 0.01}¶
- axis_config_d = {'include_ticks': False, 'include_tip': False, 'line_to_number_buff': 0.1, 'line_to_number_direction': array([-1., -1., 0.]), 'stroke_color': '#FFFFFF', 'stroke_radius': 0.01}¶
- y_axis_config_d = {'line_to_number_direction': array([-1., -1., 0.]), 'numbers_to_exclude': [0]}¶
- get_lines_parallel_to_axis(axis1: NumberLine, axis2: NumberLine) tuple[Group[Line], Group[Line]]¶