Number line

Part of Foundations

Number line preview
remixableManimCE2Daxisloop

The bedrock of any maths explainer: a horizontal axis from -5 to 5 with integer ticks, and a single dot resting at 2.3. The loop walks the dot between three marked values and returns it, easing at each stop, so it plays seamlessly. Labels, a reference grid and a live coordinate readout each ship as their own layer, so you can turn them on and off without re-rendering.

manim/number_line.py

"""Number line: a dot resting on a labelled axis, visiting marked values.

Render (the driver does this for every palette; these are for eyeballing):
    P=/opt/homebrew/opt/python@3.11/bin/python3.11
    ASSET_MODE=still  $P -m manim -s -t -r 1600,1600 manim/number_line.py NumberLine
    ASSET_MODE=motion $P -m manim -qh   -r 1600,1600 manim/number_line.py NumberLineLoop
"""

from manim import DOWN, UP, Dot, Line, Text, VGroup, always_redraw, smooth
from manim import NumberLine as NumberLineMobject

from lib.asset import FONT, FlatAsset
from lib.palette import opacity, role

LO, HI, STEP = -5, 5, 1
AXIS_LENGTH = 7.0

The full Manim source and the rendered video come with a plan.