Visualization¶
Visualization is optional and imports Matplotlib lazily.
python -m pip install "latticegeom[plot]"
Basic plot¶
import matplotlib.pyplot as plt
from latticegeom import kagome
lat = kagome((3, 3), pbc=True)
ax = lat.plot(
draw_plaquettes=True,
plaquette_arrows=True,
site_labels=True,
)
ax.set_title("Typed Kagome geometry")
plt.show()
Lattice.plot is a thin wrapper around plot_lattice. Both return a regular
Matplotlib axes and never call show().
Periodic display modes¶
The periodic= option controls relations that cross the finite box:
"unfold"places endpoints in their actual periodic image and is the default;"hide"omits boundary-crossing bonds and plaquettes;"fold"connects to wrapped finite sites with dashed segments.
Use unfold to audit super_idx and use fold for compact overview figures.
show_periodic_sites, show_boundary, show_unit_cell, and show_basis provide
additional geometric context.
Types, directions, and reverse bonds¶
Site, bond, and plaquette colors are keyed by geometry type. Override selected values
with site_colors=, bond_colors=, or plaquette_colors=. Bond arrows show declared
direction; plaquette_arrows=True shows stored loop orientation.
include_reverse=True draws derived reverse bonds without adding them to the canonical
geometry. Set arrows=False when direction is irrelevant and a batched line plot is
preferred.
External values¶
Model results can be annotated without mutating the lattice:
lat.plot(
bond_values=phase_by_bond,
plaquette_values=flux,
value_format=".3f",
)
Bond values correspond to canonical bond rows. When reverse bonds are displayed, their annotations reuse the matching canonical values. Plaquette values must contain one entry per compiled plaquette.
Embedded lattices¶
A one-dimensional lattice is drawn along a horizontal plotting axis. For embeddings above two Cartesian dimensions, choose two distinct components explicitly:
lat.plot(projection=(0, 2))
Plotting is a diagnostic view over public compiled arrays. No color map, artist, or
rendering state is stored on Lattice.