Skip to content

feat(plotting): contour and heatmap plots (imshow, contour, tripcolor, tricontour, colorbar) - #12

Merged
BenHuddart merged 4 commits into
mainfrom
feat/contour-heatmap
Jul 23, 2026
Merged

feat(plotting): contour and heatmap plots (imshow, contour, tripcolor, tricontour, colorbar)#12
BenHuddart merged 4 commits into
mainfrom
feat/contour-heatmap

Conversation

@BenHuddart

@BenHuddart BenHuddart commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Adds matplotlib-style 2-D contour/heatmap plotting backed by GLE's native surface tooling, motivated by magnetic field–temperature phase diagrams from susceptibility data:

  • imshow(Z) — gridded heatmaps via GLE's colormap command + generated .z sidecars (extent/origin/vmin/vmax/interpolation; correct on log axes). origin="lower" is the default (deviates from matplotlib — documented).
  • contour(x, y, Z) — contour lines via begin contour blocks, explicit/automatic levels, optional inline value labels (clabel).
  • tripcolor / tricontour(x, y, z) — scattered measurement data gridded at GLE compile time via begin fitz (Akima) — no scipy dependency.
  • Figure.colorbar() — self-contained colorbar subroutine; figure layout reserves right margin so nothing clips.
  • 8 palettes (viridis default, magma, inferno, plasma, cividis, coolwarm, gray, rainbow) emitted as self-contained GLE subs transcribed from gle-library sources (provenance-commented), clamped to [0,1] so fitz overshoot saturates instead of speckling.
  • Mathtext translation$\chi$-style matplotlib math in any label is translated to GLE's TeX-like markup at store time (gleplot.mathtext_to_gle is public API).
  • Full round-trip — all emitted GLE re-parses into the object model; writer→recognizer→writer is byte-identical (new golden-battery builders + fixed-point coverage); foreign hand-written colormap/fitz/contour GLE is preserved verbatim with warnings.
  • Full GUI authoring — heatmap/contour series-panel controls (palette, z-range, levels editor, colorbar) and a scattered x/y/z creation flow in the data manager; undo verified.
  • Docs/examplesdocs/guides/CONTOUR_AND_HEATMAPS.md with an antiferromagnet H–T phase-diagram worked example; examples/basic/heatmap_imshow.py, examples/advanced/phase_diagram.py.

The first commit is pure black formatting of touched modules (quote normalization), split out so the feature diff stays reviewable.

Known limitations

  • One heatmap per axes (GLE's colormap slot limit) — guarded with a clear error.
  • Colorbar on a non-rightmost subplot column may overlap its neighbour (margin is reserved figure-wide).
  • tricontour level ranges can't be validated at store time (grid exists only at GLE compile time).
  • GLE 4.3.9 as built on macOS ARM CI runners crashes (silently, mid-render) on begin contour blocks — isolated by CI experiment (fitz-only scripts pass; Linux passes with the identically pinned build; upstream has no functional changes since v4.3.9). The contour-bearing compile test is non-strict xfail on darwin; this is an upstream GLE platform issue, not an emission bug.

Test plan

  • Full suite: 1442 passed, 2 skipped (baseline before feature: 748) — unit, parser (fixed-point/golden battery), integration (real GLE 4.3.10 compiles), and GUI (PySide6 offscreen).
  • Adversarial review pass: round-trip on hostile figure combinations, mathtext edge cases, NaN/degenerate-input guards, palette values verified 270/270 against gle-library sources, Python 3.7-floor syntax check.
  • Compiled example PNGs visually verified (colorbar visible, Greek χ labels render, contour traces the Néel boundary).

🤖 Generated with Claude Code

BenHuddart and others added 4 commits July 23, 2026 12:00
Pure formatting (mostly quote normalization) with no functional changes,
separated out so the feature diff stays reviewable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…g and colorbars

Add matplotlib-style 2-D plotting backed by GLE's native surface tooling:

- imshow(Z): gridded heatmaps via the GLE colormap command and generated
  .z sidecar files; extent/origin/vmin/vmax/interpolation supported;
  renders correctly on log axes
- contour(x, y, Z): contour lines via begin-contour blocks with explicit
  or automatic levels and optional inline value labels (clabel)
- tripcolor/tricontour(x, y, z): scattered-data variants (e.g. magnetic
  susceptibility measurements) gridded at GLE compile time by begin-fitz
  Akima interpolation - no scipy dependency
- Figure.colorbar(): self-contained colorbar subroutine with automatic
  right-margin reservation so single-axes figures no longer clip it
- eight palettes (viridis default, magma, inferno, plasma, cividis,
  coolwarm, gray, rainbow) emitted as self-contained GLE subroutines
  transcribed from gle-library sources; values clamped to [0,1] so
  fitz overshoot saturates instead of speckling
- mathtext_to_gle(): matplotlib $...$ math in labels is translated to
  GLE's TeX-like markup at store time (Greek letters, sub/superscripts)
- full parser/recognizer round-trip: emitted GLE re-parses into the
  object model with byte-identical writer-recognizer-writer fixed point;
  foreign hand-written colormap/fitz/contour GLE is preserved verbatim
- full GUI authoring: heatmap/contour series panels (palette, z-range,
  levels editor, colorbar controls) and scattered x/y/z creation flow
  in the data manager
- guide (docs/guides/CONTOUR_AND_HEATMAPS.md) with an antiferromagnet
  field-temperature phase diagram worked example, plus runnable examples

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GLE 4.3.9 built on the macOS ARM CI runners aborts with no error output
while rendering scripts containing begin-fitz/begin-contour blocks; the
identically pinned Linux build compiles them fine and upstream GLE has
no functional changes between v4.3.9 and master, so this is a platform
crash in GLE's Akima/contour code rather than a gleplot emission bug.

Marks the scattered-data compile test xfail (non-strict) on darwin and
adds a tripcolor-only sibling with the same marker so the macOS job's
XFAIL/XPASS report shows which GLE stage (fitz vs contour) crashes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CI experiment result: fitz-only compilation XPASSes on both macOS jobs
while the begin-contour script XFAILs, so the platform crash is in GLE's
contour stage, not fitz. The tripcolor-only test now runs as a hard
assertion everywhere; only the contour-bearing test stays xfail on
darwin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BenHuddart
BenHuddart merged commit d8812a3 into main Jul 23, 2026
4 checks passed
@BenHuddart
BenHuddart deleted the feat/contour-heatmap branch July 23, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant