manim.mobject.coordinate_systems.Axes

class Axes(x_range=None, y_range=None, x_length=12, y_length=6, axis_config=None, x_axis_config=None, y_axis_config=None, **kwargs)[source]

Bases: manim.mobject.types.vectorized_mobject.VGroup, manim.mobject.coordinate_systems.CoordinateSystem

Creates a set of axes.

Parameters
  • x_range (Optional[Union[list, numpy.ndarray]]) – The [x_min, x_max, x_step] values of the x-axis.

  • y_range (Optional[Union[list, numpy.ndarray]]) – The [y_min, y_max, y_step] values of the y-axis.

  • x_length (Optional[float]) – The length of the x-axis.

  • y_length (Optional[float]) – The length of the y-axis.

  • axis_config (Optional[dict]) – Arguments to be passed to NumberLine that influences both axes.

  • x_axis_config (Optional[dict]) – Arguments to be passed to NumberLine that influence the x-axis.

  • y_axis_config (Optional[dict]) – Arguments to be passed to NumberLine that influence the y-axis.

  • kwargs (Any) – Additional arguments to be passed to CoordinateSystem and VGroup.

Methods

add_coordinates

coords_to_point

create_axis

Creates an axis and dynamically adjusts its position depending on where 0 is located on the line.

get_axes

get_coordinate_labels

get_line_graph

Draws a line graph.

point_to_coords

update_default_configs

Attributes

animate

Used to animate the application of a method.

depth

The depth of the mobject.

height

The height of the mobject.

width

The width of the mobject.

create_axis(range_terms, axis_config, length)[source]

Creates an axis and dynamically adjusts its position depending on where 0 is located on the line.

Parameters
  • range_terms (Union[list, numpy.ndarray]) – The range of the the axis : (x_min, x_max, x_step).

  • axis_config (dict) – Additional parameters that are passed to NumberLine.

  • length (float) – The length of the axis.

get_line_graph(x_values, y_values, z_values=None, line_color='#FFFF00', add_vertex_dots=True, vertex_dot_radius=0.08, vertex_dot_style=None, **kwargs)[source]

Draws a line graph.

The graph connects the vertices formed from zipping x_values, y_values and z_values. Also adds Dots at the vertices if add_vertex_dots is set to True.

Parameters
  • x_values (Iterable[float]) – Iterable of values along the x-axis.

  • y_values (Iterable[float]) – Iterable of values along the y-axis.

  • z_values (Optional[Iterable[float]]) – Iterable of values (zeros if z_values is None) along the z-axis.

  • line_color (manim.utils.color.Colors) – Color for the line graph.

  • add_vertex_dots (bool) – Whether or not to add Dot at each vertex.

  • vertex_dot_radius (float) – Radius for the Dot at each vertex.

  • vertex_dot_style (Optional[dict]) – Style arguments to be passed into Dot at each vertex.

  • kwargs – Additional arguments to be passed into VMobject.

Return type

manim.mobject.types.vectorized_mobject.VDict

Examples

Example: LineGraphExample

../_images/LineGraphExample-1.png
from manim import *

class LineGraphExample(Scene):
    def construct(self):
        plane = NumberPlane(
            x_range = (0, 7),
            y_range = (0, 5),
            x_length = 7,
            axis_config={"include_numbers": True},
        )
        plane.center()
        line_graph = plane.get_line_graph(
            x_values = [0, 1.5, 2, 2.8, 4, 6.25],
            y_values = [1, 3, 2.25, 4, 2.5, 1.75],
            line_color=GOLD_E,
            vertex_dot_style=dict(stroke_width=3,  fill_color=PURPLE),
            stroke_width = 4,
        )
        self.add(plane, line_graph)