ImPlot-powered Jupyter plotting widget for interactive, million-point visualizations.
Project description
nbimplot
Jupyter-native plotting focused on high interactivity and large time-series support.
Current implementation includes:
- Notebook-only widget canvas rendering
- Binary transport (
numpy -> bytes -> wasm memory) - WASM core for plot state, autoscale, and min/max LOD generation
- Strict WASM runtime requirement (JS fallback disabled)
- ImPlot-required mode (
prefer_implot=True,strict_wasm=Trueonly) - Lifecycle-safe cleanup for repeated cell execution
- Subplots via
nbimplot.Subplots - Expanded primitive APIs:
scatter,bubbles,stairs,stems,digital,bars,bar_groups,bars_h,shaded,error_bars,error_bars_h,inf_lines,vlines,hlines,histogram,histogram2d,heatmap,image,pie_chart,text,annotation,dummy
Quick start
import numpy as np
import nbimplot as ip
y = np.sin(np.linspace(0, 100, 1_000_000, dtype=np.float32))
p = ip.Plot(width=900, height=450, title="Signal")
h = p.line("mid", y)
p.show()
h.set_data(y * 0.8)
p.render()
API
import nbimplot as ip
p = ip.Plot(width=900, height=450, title="Signal")
h = p.line("mid", y, x_axis="x1", y_axis="y1", subplot_index=0)
h.set_data(y_new)
p.render()
p.show()
prefer_implot=False and strict_wasm=False are not supported.
Additional controls:
p.set_view(x_min, x_max, y_min, y_max)p.autoscale()p.set_axis_scale(x="linear|log", y="linear|log")p.set_plot_flags(...)for native ImPlot flags (no_legend,no_menus, etc.)p.set_axis_state("x2|x3|y2|y3", enabled=True|False, scale="linear|log|time")p.set_axis_label(...),p.set_axis_format(...),p.set_axis_ticks(...),p.clear_axis_ticks(...)p.set_axis_limits_constraints(...),p.set_axis_zoom_constraints(...),p.set_axis_link(...)p.set_secondary_axes(x2=..., x3=..., y2=..., y3=...)p.set_time_axis("x1|x2|x3|y1|y2|y3")p.set_colormap("Deep|Dark|Pastel|Paired|Viridis|Plasma|Hot|Cool|Pink|Jet|Twilight|RdBu|BrBG|PiYG|Spectral|Greys")- Most primitive APIs support
x_axis="x1|x2|x3"andy_axis="y1|y2|y3" p.line(..., color=\"#3b82f6\", line_weight=2.0, marker=\"circle\", marker_size=5.0)andhandle.set_style(...)p.stream_line(..., capacity=N)andhandle.append(...)for in-place ring-buffer style updatesp.hide_next_item()to hide the next added series/primitive without removing itp.heatmap(..., label_fmt="%.2f", scale_min=None, scale_max=None)andlabel_fmt=""to hide cell-value textp.heatmap(..., show_colorbar=True, colorbar_label="Intensity", colorbar_format="%g", colorbar_flags=0)p.histogram2d(..., show_colorbar=True, colorbar_label="Count", colorbar_format="%g", colorbar_flags=0)p.image(..., bounds=((x0, y0), (x1, y1)), uv0=(0, 0), uv1=(1, 1))for trueImPlot::PlotImagerendering (zcan be 2D grayscale orH x W x 3/4RGB(A))p.tag_x(...),p.tag_y(...),p.colormap_slider(...),p.colormap_button(...),p.colormap_selector(...)p.drag_drop_plot(...),p.drag_drop_axis(...),p.drag_drop_legend(...)p.on_perf_stats(callback, interval_ms=500)for live FPS/WASM timingsp.on_tool_change(callback)for drag tool updatesp.on_selection_change(callback)for box-selection/query updates
Interactive tools:
p.drag_line_x(...)p.drag_line_y(...)p.drag_point(...)p.drag_rect(...)
Subplots (Native ImPlot)
import nbimplot as ip
import numpy as np
sp = ip.Subplots(
2,
2,
title="Dashboard",
width=1000,
height=700,
link_rows=True,
link_cols=True,
share_items=True,
)
sp.subplot(0, 0).line("line", np.sin(np.linspace(0, 20, 5000, dtype=np.float32)))
sp.subplot(0, 1).scatter("pts", np.random.randn(2000).astype(np.float32))
sp.subplot(1, 0).bars("bars", np.abs(np.random.randn(120)).astype(np.float32))
sp.subplot(1, 1).histogram("hist", np.random.randn(20_000).astype(np.float32), bins=40)
sp.show()
Subplots(...) supports axis-linking controls:
link_rows: link y-axis within each rowlink_cols: link x-axis within each columnlink_all_x: link x-axis for all cellslink_all_y: link y-axis for all cells- Additional compatibility flags:
share_items,no_legend,no_menus,no_resize,no_align,col_major
Aligned-group helper:
ip.AlignedPlots(rows, cols, group_id="aligned", vertical=True, ...)
Example Notebook
notebooks/nbimplot_examples.ipynbnotebooks/nbimplot_api_gallery.ipynbnotebooks/nbimplot_benchmarks.ipynb
Build WASM core
Prerequisites
- Emscripten SDK (
emcmake,emcc) - CMake >= 3.20
Build (WASM core only)
scripts/build_wasm.sh
Outputs are written to nbimplot/wasm/:
nbimplot_wasm.jsnbimplot_wasm.wasm
If outputs are missing or invalid, the widget reports a runtime error.
Build with ImPlot sources
ImPlot is required for runtime. Build with Dear ImGui + ImPlot sources:
NBIMPLOT_WITH_IMPLOT=ON \
NBIMPLOT_IMGUI_DIR=/path/to/imgui \
NBIMPLOT_IMPLOT_DIR=/path/to/implot \
scripts/build_wasm.sh
If you cloned deps into third_party/imgui and third_party/implot, this also works:
NBIMPLOT_WITH_IMPLOT=ON scripts/build_wasm.sh
Notes:
wasm/core/nbimplot_implot_layer.cppcreates ImGui/ImPlot contexts when compiled withNBIMPLOT_WITH_IMPLOT=1.- The final WebGL backend draw hookup is intentionally isolated behind the
ImPlotLayer::render(...)seam.
Performance behavior
- Raw rendering path when visible points
<= 3 * pixel_width - Min/max bucket LOD path when visible points
> 3 * pixel_width - LOD decision and output generation happen in WASM
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nbimplot-0.1.1.tar.gz.
File metadata
- Download URL: nbimplot-0.1.1.tar.gz
- Upload date:
- Size: 390.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a3e43d09ca03c882c6a91be68ae5c2e221242505c9fcd0a43b225e94a128521
|
|
| MD5 |
d809ec9e37596ab5be114200ad581102
|
|
| BLAKE2b-256 |
16718edc708185d4a398a5e6f3836d82e4734725d155e31b9a130211ee7875b4
|
File details
Details for the file nbimplot-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nbimplot-0.1.1-py3-none-any.whl
- Upload date:
- Size: 391.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
922e43b6e89ec1141661a433aaa72e972d9a01c3e814885726bcd959f2d4fabd
|
|
| MD5 |
9f3df2f98931be05ec9197a652805e39
|
|
| BLAKE2b-256 |
c516071cfd3485067561c57a060c662055af3febfa910bc1a53579d58beef82c
|