plot_envelope.py grows a --show flag. With it, matplotlib's WebAgg backend spins up a localhost server with a real interactive figure (zoom, pan, hover, axes lock) — equivalent to a matlab plot window without needing tkinter or Qt locally. tools/show_envelope.sh is a NixOS-aware wrapper: it locates libstdc++.so.6 in /nix/store (numpy's prebuilt wheel needs it on LD_LIBRARY_PATH) and then exec's the python script with --show. Default port 8988, override via --port. Bound to 0.0.0.0 so the figure is reachable over WG too. tornado is added to dev deps because WebAgg requires it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
1.2 KiB
Bash
Executable file
32 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Open an interactive envelope plot in your browser (matplotlib WebAgg).
|
|
#
|
|
# On NixOS, the prebuilt numpy wheel needs libstdc++ from gcc-lib on
|
|
# LD_LIBRARY_PATH; this wrapper finds it automatically.
|
|
#
|
|
# Usage:
|
|
# tools/show_envelope.sh <episode_dir> [--port 8988]
|
|
#
|
|
# Then open the printed URL (or your browser may pop open automatically).
|
|
# Ctrl-C in this terminal to stop the server.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
# Locate libstdc++.so.6 in /nix/store. Prefer the gcc-lib derivation.
|
|
LIBSTDC=$(find /nix/store -maxdepth 4 -name 'libstdc++.so.6' -path '*gcc*-lib/lib/*' 2>/dev/null | head -1)
|
|
if [[ -z "${LIBSTDC:-}" ]]; then
|
|
# Fall back to any libstdc++ in /nix/store.
|
|
LIBSTDC=$(find /nix/store -maxdepth 4 -name 'libstdc++.so.6' 2>/dev/null | head -1)
|
|
fi
|
|
if [[ -z "${LIBSTDC:-}" ]]; then
|
|
echo "could not locate libstdc++.so.6 in /nix/store" >&2
|
|
echo "(numpy needs it; install via 'nix-shell -p stdenv.cc.cc.lib' or set LD_LIBRARY_PATH manually)" >&2
|
|
exit 1
|
|
fi
|
|
LIB_DIR="$(dirname "$LIBSTDC")"
|
|
|
|
LD_LIBRARY_PATH="$LIB_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
|
|
exec uv run python tools/plot_envelope.py --show "$@"
|