A gallery of small runnable scripts, each in its own folder with a
run.py you can copy-run, a README.md that explains what the code
is teaching, and a pre-generated snapshot.html you can open in a
browser to see what the live plot looked like at the end of the run.
Each snapshot is a single self-contained HTML file with uPlot's JS and CSS inlined plus the recorded trace data. No server, no Python, no internet required to view it. Click the snapshot link, get a live interactive plot you can pan and zoom.
The snapshot links below open the static HTML files directly. GitHub won't render them inline in this README, so if you're reading this on github.com click the links to see the snapshot through the htmlpreview proxy. If you clone the repo, just open
snapshot.htmllocally.
Every example folder ships two forms of the same script — a raw-dict version and a typed-dataclass version — so you can read them side-by-side and pick whichever style you prefer. Both serialize to the identical on-the-wire config.
| What it teaches | Dict form | Typed form | Snapshot | |
|---|---|---|---|---|
| 01 – Hello, sine wave | The minimum three client calls: local_plot, initialize_plots, send_array. |
run.py | run_typed.py | snapshot |
| 02 – Multiple subplots | Multi-plot layouts, multi-trace plots, per-plot styling, flat-list send_array. |
run.py | run_typed.py | snapshot |
| 03 – Interactive controls | Buttons, sliders, dials, and display boxes that drive your Python loop live. | run.py | run_typed.py | snapshot |
| 04 – Colored controls | Same as 03, plus the color option on buttons, slider, and dial. |
run_dict.py | run.py | — |
Each example script assumes a browser server is already running. Start one in a separate terminal first:
python -m rtplot.server_browserThen from this examples/ directory:
cd 01_hello_world
python run.pyThe script prints the absolute path of the snapshot file when it finishes. Open that path in a browser to see the captured plot.
The snapshots committed here are generated by running each run.py
in turn, so they can be rebuilt from scratch any time. A convenience
one-liner from this directory:
for d in */; do (cd "$d" && python run.py); doneOr just rerun whichever example you changed. Each script is self-contained and the snapshot it writes replaces the one that was there.