Jupyter Notebooks¶
The Visualizer detects Jupyter/IPython automatically and adapts behaviour
for notebook environments: show() renders inline, run() is unavailable,
and the serverless display_snapshot() produces static embeds. Under Jupyter,
Visualizer() is a singleton — re-running a construction cell reuses the same
instance and resets the default scene.
Auto-detection¶
open_browserdefaults toFalse(no popup).run()is not available — it would block the kernel indefinitely.- Use the
start_server()/flush()/stop_server()non-blocking pattern instead (orshow()to also open a browser). - When the
Visualizerobject is the last expression in a notebook cell, it renders an inline<iframe>via the_repr_html_()method.
Re-running cells¶
Visualizer() is a singleton under Jupyter — re-running a cell that
re-creates it returns the same instance (one server, one scene host) instead of
trying to bind the port again. Re-running a construction cell also clears
the default scene and re-adds axes/grid per add_default_axes /
add_default_grid. A scene created with viz.scene(name) is cleared when the
same cell is re-run, but get-or-create when a different cell touches it. See
Use Cases — Notebooks for the full caveats.
Live vs static¶
| Need | Use | Page |
|---|---|---|
| Rotate / zoom / animate live | start_server() + flush() + _repr_html_() |
Live inline display |
| Quick static snapshot | display_snapshot() |
Static inline display |
How it works¶
start_server()launches the aiohttp server in a background daemon thread. The server survives across notebook cells untilstop_server()is called.flush()pushes scene state to all connected browsers — call it after adding or modifying entities._repr_html_()returns an<iframe>pointing to the server URL. Jupyter calls this automatically when theVisualizerobject is the last expression in a cell.stop_server()releases the port and terminates the background thread. Always call it when done to free resources.
Topics¶
| Guide | What you will learn |
|---|---|
| Live inline display | start_server()/flush()/_repr_html_(), idempotent show()/display(), display_row(mode="live") |
| Static inline display | display_snapshot() and display_row(mode="static") — serverless, embeddable viewers |
Limitations¶
- Remote Jupyter (Colab, Binder, remote kernels): The iframe points to
localhost, which is the server machine, not your local browser. The viewer won't be reachable. Open the printed URL in a separate browser tab on the machine running the kernel. - Port conflicts:
start_server()defaults to port 8765; passport=...to choose another, orport=0to auto-pick a free port. - Multiple scenes: Create named scenes via
viz.scene("name")instead of multipleVisualizerinstances — all scenes share one server on one port.