Ostrin Viz 0.1

Scientific figures,
drawn by Ostrin.

std.viz is the visualization library of the Ostrin standard library, written in Ostrin itself. A figure is data (a list of series); rendering it lays out ticks, legends, colormaps and 3D projections and writes a standalone SVG. The interpreter, the native C backend and the compiler running in this page produce the same bytes.

2D and 3Dunit-aware axestables and animationruns in your browser
01 / DESCRIBE

A figure is a value.

viz.figure(title) and viz.scene3d(title) return records; each mark (line, band, histogram, heatmap, surface…) appends a series. Named and default arguments keep calls short.

02 / LAY OUT

Ostrin does the geometry.

1-2-5 ticks, legends placed in the emptiest corner, marching-squares contours, an orthographic camera, painter's algorithm and directional light: all of it is Ostrin code.

03 / RENDER

Standalone SVG.

fig.svg() returns the document and fig.save(path) writes it. Units travel with the data: plotting Array<Quantity<D>> labels the axes speed [km/h].

examples/viz_units.ostrin
import std.viz

fn main() -> Void {
    times = [0 s, 5 s, 10 s, 15 s, 20 s]
    speeds = [0 m/s, 6.1 m/s, 11.4 m/s, 15.8 m/s, 19.4 m/s]
    in_kmh = speeds.map(fn(v) { v as km/h })
    fig = viz.figure("Car acceleration")
        .labels("time", "speed")
        .unit_line(times, in_kmh, label: "measured")
    print(fig.svg())   // axes: "time [s]" and "speed [km/h]"
}

Featured workflows

Follow a scientific question from source to evidence.

These guided paths reuse the same source-backed figures below. Select a path to share it with ?workflow=..., then open its plot, table, animation or provenance record.

Gallery

Every figure is a program you can run.

Each image below is the SVG its program printed when this site was built with ostrinc.wasm. Press Run live to recompute it in this page. Explore a figure and copy its URL to share the selected parameters or 3D camera. Download its small ostrin.figure/v0 manifest to keep the source link, artifact path, capability tags, recorded provenance and current explorer state together, or open Cite for a BibTeX handoff with that same URL. All 30 bundle-backed gallery figures now offer a versioned ostrin.experiment/v0 download with declared inputs, calculated hashes and exact SVG replay verified in website CI; each bundle also records a partial ostrin.runtime/v1 target/WASI snapshot, available lockfile hashes and the verified invocation hash for its SVG. All eleven input-driven bundles now carry embedded input snapshots and declared filesystem capabilities, so their parameter or seed replays are labelled R2; the nine seeded bundles retain source-backed R1 algorithm evidence. The remaining 18 bundles stay at R0. The three polished figures (viz_polished_*) are recorded SVG cards without an experiment bundle yet.

Recorded SVGs load immediately. The browser compiler starts only when you choose Run live or open an interactive explorer.

Status

What std.viz does today, and what is next.

Available

  • line, scatter, area, band, error bars, bars, histogram, grouped boxplots, kernel-density violins, hexbin density, 2D quiver vector fields and streamplot streamlines, stairs, reference lines, notes
  • heatmap, discrete filled contour bands and contour lines with colorbars
  • 3D surface, wireframe, trajectory, point cloud, sampled vector fields with arrowheads, orthogonal scalar-volume slices and marching-tetrahedra isosurfaces; azimuth/elevation camera
  • 3D gallery exploration with azimuth/elevation sliders that rerun the Ostrin source in WASM, plus reset-to-source view
  • declarative source-parameter sliders that rewrite the selected Ostrin program and rerun it in WASM (surface scale and Lorenz ρ are live examples)
  • legends with stable series identifiers and accessible web toggles to focus or restore each series, 1-2-5 ticks, light and dark themes, viridis/magma/coolwarm/ocean
  • multi-panel layouts with viz.grid
  • continuous motion computed by Ostrin: moving points with trails, rods, curves that change shape (animate, moving_point, rod, morph), interpolated by SVG <animate> with no scripts
  • flip-book animations with viz.animate (frames played by CSS, pause on hover)
  • SVG tables from viz.table with formatted cells, zebra rows, dark theme and native SVG tooltips
  • the table explorer filters and sorts rows produced by Ostrin while preserving the SVG output
  • linked selection between indexed scatter points and table rows, with click and keyboard activation
  • declarative .bind(channel, event) contracts for hover, focus and select across indexed marks in multiple figures
  • the web explorer adds play, pause, restart, a timeline, speed and loop-count controls, reduced-motion handling, crosshair data inspection and browser-side WebM or capability-detected MP4 export when MediaRecorder exposes the codec
  • download of the current SVG plus 2× PNG export, including a selected animation frame
  • download of a self-contained interactive HTML export with the selected SVG frame, provenance, zoom, pointer panning and crosshair inspection
  • WebM, capability-detected MP4 and GIF animation exports offer selectable 1×/2× canvas quality and announce the output scale
  • print-ready PDF export keeps the selected vector frame, page dimensions and provenance metadata; the browser's native dialog saves it as PDF
  • animated GIF export encodes Ostrin's SVG frames in the browser and records provenance in the GIF comment extension
  • hover highlights and value tooltips inside the SVG (no scripts), explorable here with zoom and pan
  • axis units from Array<Quantity<D>> or List<Quantity<D>> data
  • reproducibility metadata for figures, tables and 3D scenes: source/data hashes, seed and compiler identity embedded in the SVG and shown in each gallery card
  • downloadable ostrin.figure/v0 manifests keep each figure's source, SVG path, capability tags, recorded provenance and selected explorer state
  • shareable explorer URLs restore the selected figure, Ostrin parameters and 3D camera without a server-side session
  • citation handoff with BibTeX and machine-readable metadata for the selected figure URL and source

Planned

  • higher-quality video export and a server-independent codec fallback for browsers without MP4 MediaRecorder support
  • a WebGPU backend for large meshes, full volume rendering and large particle scenes
  • Array<Measurement<T>>, covariance blocks and coverage-aware plots; the gallery already demonstrates scalar series projected into standard-deviation error bars

Current limits: rendering is CPU-side SVG, comfortable up to a few thousand triangles.