3-D text walk¶
The bundled chapter as a 3-D corkscrew: the same space-filling turtle walk, but
each sentence also climbs a constant step in z, so the rectangular walk winds
upward. Rendered with matplotlib's mplot3d.
"""3-D text-walk demo: the chapter lifted into a corkscrew.
Run with: uv run python examples/text_walk_3d_demo.py
Writes text_walk_3d.png to the current directory.
"""
from lexograph import load_demo_text, segment, text_walk
def main() -> None:
"""Walk the bundled chapter as a 3-D corkscrew, coloured by position."""
text = load_demo_text()
units = segment(text, unit="sentences")
print(f"Winding {len(units)} sentences into a corkscrew.")
fig = text_walk(
text,
colour=list(range(len(units))),
helix=True,
z_step=4.0,
)
fig.savefig("text_walk_3d.png", dpi=150)
print("Saved text_walk_3d.png")
if __name__ == "__main__":
main()
Run it with:
It is the same text_walk preset as the 2-D walk, with helix=True. Raise
z_step for a taller, more tightly wound corkscrew.