Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.95 KB

File metadata and controls

64 lines (48 loc) · 2.95 KB

rtplot examples

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.html locally.

Examples

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

How to run an example

Each example script assumes a browser server is already running. Start one in a separate terminal first:

python -m rtplot.server_browser

Then from this examples/ directory:

cd 01_hello_world
python run.py

The script prints the absolute path of the snapshot file when it finishes. Open that path in a browser to see the captured plot.

Regenerating all snapshots

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); done

Or just rerun whichever example you changed. Each script is self-contained and the snapshot it writes replaces the one that was there.