hexalate
Docs
GitHub
PyPI
Python — hexalate playground
⏳ Loading…
import hexalate as hx # Create a 10x8 pointy-top grid grid = hx.HexGrid(10, 8, 0.5) print(f"Grid has {len(grid)} hexagons") # Axial coordinate lookup h = grid.get(2, 3) print(f"Hex (2,3): center=({h.x:.2f}, {h.y:.2f}), s={h.s}") print(f"Neighbors: {len(grid.neighbors(2, 3))}") # Distance between two hexes a = grid.get(0, 0) b = grid.get(4, 2) print(f"Distance (0,0) → (4,2): {a.distance_to(b)}") # Export to DataFrame df = grid.to_dataframe() print(df.head(3).to_string()) # Plot colored by distance from center — saves to /tmp/out.png import math cx = sum(h.x for h in grid) / len(grid) cy = sum(h.y for h in grid) / len(grid) origin = min(grid, key=lambda h: (h.x-cx)**2 + (h.y-cy)**2) values = [origin.distance_to(h) for h in grid] grid.plot( values=values, colormap="coolwarm", output="/tmp/out.png", figsize=(8, 6), ) print("Plot saved — check the Image tab ↗")
Console
Image
Loading Python (Pyodide) — first load takes ~10s…
Run code that saves a plot to /tmp/out.png
and it will appear here.
Initialising…
Python 3.x · Pyodide · hexalate