Skip to content

Bug found: Axes renders its axis line in the wrong place whenever the range is asymmetric about zero #1

Description

@johnhenry

Bug found: Axes renders its axis line in the wrong place whenever the range is asymmetric about zero

Image ![Bug repro — dots placed at c2p(0, 0.5) and c2p(70, 0.5) don't sit on the axis line below them]({{artifact:c00a8910-a08d-4446-9194-356d60efd19d}})

Root cause (src/mobject/coordinate_systems.ts): Axes builds each NumberLine centered on world-origin, then calls xAxis.shift(-xAxis.numberToPoint(xRef)) to slide the rendered axis line so its zero-reference lands at the world origin. That shift mutates the axis's drawn points — but NumberLine.numberToPoint() (the function Axes.c2p() calls for every plotted point, dot, or line) is never updated to account for the shift; it still uses the pre-shift leftX. The result: the visible axis line moves, but every coordinate computed through c2p() doesn't.

For a symmetric range like [-4, 4] (the value in ecmanim's own bundled graph.ts example), the shift happens to be zero, so the bug is invisible — which is exactly why it slipped through their existing example and test suite. Our birthday-paradox scene used xRange: [0, 70], and I verified algebraically that any range where the reference point isn't the midpoint (e.g. [0,70], [10,20]) produces a mismatch — in our case a 4.5-unit horizontal offset, which is exactly the gap visible between the amber curve and the axis tick marks in the earlier frames you flagged.

I confirmed this is a real ecmanim defect, not a sandbox or scene-script issue, by:

  1. Deriving the offset algebraically from the library's own source and testing it across four different xRange/xLength combinations.
  2. Writing a minimal repro scene using only Axes + Dot + c2p() — no custom math, no scene logic of mine — that reproduces the same visible offset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions