dear-implot3d
High-level Rust bindings for ImPlot3D, integrating with dear-imgui-rs.
This crate sits on top of dear-implot3d-sys (FFI to cimplot3d) and mirrors
the ergonomics of dear-implot.
Links
- Upstream: https://github.com/brenocq/implot3d
- C API: https://github.com/cimgui/cimplot3d
Compatibility
Use Rust 1.95 or newer and keep all dear-* dependencies on the 0.23 release train. See the 0.23 migration notes.
| Item | Version |
|---|---|
| Crate | 0.23.0 |
| dear-imgui-rs | 0.23.0 |
| dear-implot3d-sys | 0.23.0 |
WASM (WebAssembly) support
For the experimental wasm32-unknown-unknown target, enable wasm on both direct dependencies.
[]
= { = "0.23", = ["wasm"] }
= { = "0.23", = ["wasm"] }
From the matching workspace checkout, build the demo and its imgui-sys-v1 provider with the checked-in bindings.
The 0.23 browser application uses WasmProviderAllocator and imports the provider's memory and function table. Rebuild and deploy both modules together when upgrading from 0.22. See the tool versions and local demo and application setup.
Features
- Safe, idiomatic Rust API - Type-safe wrappers over the C API
- Builder pattern - Fluent API for configuring plots
- Scoped plots - Separate setup and drawing closures with automatic native cleanup
- Type-safe flags - Using
bitflags!for compile-time safety - Modular plot types - Separate modules for each plot type
- f32/f64 support - Separate functions for different numeric types
- Optional
mintsupport - Interoperability with math libraries (glam, nalgebra, cgmath, etc.) - Predefined meshes - Cube, sphere meshes included
- Comprehensive API - Line, scatter, surface, triangle, quad, mesh, image, and text plots
Quick Start
Create Plot3DContext once alongside your ImGui context. Call the drawing function from an initialized frame.
use Ui;
use *;
Use .build(|plot| { ... }) for a plot with default axes. With .build_with_setup, the first
closure receives &Plot3DSetup and the second receives &Plot3DScope. Submit each Plot3D
item with .plot(plot) or .try_plot(plot). Both builders return None when the plot is skipped.
The builder ends each open plot in its original window and table cell, including on unwind.
Examples
Start with examples/03-features/implot3d_minimal.rs for a copy-ready integration. See
examples/03-features/implot3d_showcase.rs for the comprehensive demo that mirrors the official
ImPlot3D C++ demo.
Run either target with:
Predefined Meshes
The meshes module provides ready-to-use mesh data. Submit it inside the plot's drawing closure.
use *;
plot_ui.begin_plot.build;
For application-supplied indices, plot.mesh(label, vertices, indices).try_plot() returns a Plot3DError if the mesh cannot be submitted.
Mint Support
When the mint feature is enabled, you can use mint::Point3<f32> types:
use Point3;
let points = vec!;
plot.plot_line_mint;
Item Styling
Spec-backed plot builders expose a shared per-item styling surface through
Plot3DItemStyle / Plot3DItemStyled, plus common item flags through
Plot3DItemFlagged:
use *;
let line = f32
.with_line_color
.with_line_weight
.with_marker
.with_marker_size
.with_item_flags;
line.plot;
plot
.surface_f32
.with_fill_alpha
.with_line_color
.plot
.expect;
Surface axis inputs are validated and expanded to one X/Y value per Z sample in row-major
order. For callers that already own contiguous per-vertex arrays, use the allocation-free safe
surface_f32_flat path. Custom offsets and strides are available only through the explicitly
unsafe surface_f32_raw escape hatch.
plot.set_next_line_style, set_next_fill_style, and set_next_marker_style apply to the next
item in that open plot. Use plot_ui.with_style_vars(&[Plot3DStyleVar::FillAlpha(0.5)], || { ... }),
with_style_colors, or with_colormap to override context style across several submissions or plots.
These closures restore all pushed values on return or unwind.
Notes
- The underlying C API comes from
cimplot3dwhich depends onimplot3d. Ensure git submodules are initialized with--recursive.
License
See workspace root.