Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Dear ImPlot - Rust Bindings
High-level Rust bindings for ImPlot, the immediate mode plotting library. This crate provides safe, idiomatic Rust bindings designed to work seamlessly with dear-imgui (C++ bindgen) rather than imgui-rs (cimgui).
Features
- Safe, idiomatic Rust API - Memory-safe interfaces with proper lifetime management
- Full compatibility with dear-imgui - Uses the same context management patterns
- Builder pattern for plots - Fluent, ergonomic API for creating plots
- Comprehensive plot types - Support for all major plot types including:
- Line plots and scatter plots
- Bar charts and histograms (1D and 2D)
- Heatmaps and pie charts
- Error bars and shaded plots
- Stem plots and more
- Advanced features - Subplots, multi-axis plots, and legend management
- Modular design - Each plot type is in its own module for better organization
- Universal plot builder - Unified API for creating any plot type
Quick Start
Add to your Cargo.toml:
[]
= "0.11"
= { = "path/to/dear-implot" }
Basic usage:
use *;
use *;
Plot Types
Line and Scatter Plots
// Line plot
new.plot;
// Scatter plot
new.plot;
Bar Charts
// Simple bar chart
new
.with_bar_size
.plot;
// Positional bar chart
new
.with_bar_size
.plot;
Histograms
// 1D Histogram
new
.with_bins
.density
.cumulative
.plot;
// 2D Histogram
new
.with_bins
.plot;
Heatmaps
let data: = .map.collect;
new
.with_scale
.with_bounds
.with_label_format
.plot;
Pie Charts
let labels = vec!;
let values = ;
new
.normalize
.exploding
.with_angle0
.plot;
Error Bars
let errors = ;
new
.horizontal
.plot;
Shaded Plots
// Shaded area plot
new
.with_y_ref
.plot;
// Shaded between two curves
new
.plot;
Advanced Features
Subplots
if let Ok = new
.with_size
.with_flags
.begin
Multi-Axis Plots
let mut multi_plot = new
.add_y_axis
.add_y_axis;
if let Ok = multi_plot.begin
Universal Plot Builder
For a more unified API, you can use the PlotBuilder:
// Line plot
line.build?;
// Bar plot
bar.build?;
// Histogram
histogram.build?;
// Heatmap
heatmap.build?;
Error Handling
All plot functions return Result<(), PlotError> for proper error handling:
match new.validate
Integration with Dear ImGui
This crate is designed to work seamlessly with the dear-imgui ecosystem:
- Uses the same context management patterns as dear-imgui
- Compatible with dear-imgui's UI tokens and lifetime management
- Shares the same underlying Dear ImGui context
- Follows the same safety and ergonomics principles
Examples
See the examples/ directory for complete working examples:
plot_gallery.rs- Comprehensive showcase of all plot typesadvanced_features.rs- Subplots and multi-axis examplesreal_time_plotting.rs- Dynamic data visualization
Building
This crate requires:
- Rust 1.70 or later
- C++ compiler (for building ImPlot)
- CMake (for building dependencies)
The build process automatically handles:
- Building ImPlot from source
- Generating C++ wrapper functions
- Linking with dear-imgui
Architecture
This crate follows the same architectural patterns as dear-imgui:
- Context Management: Separate ImPlot context that works alongside Dear ImGui
- Lifetime Safety: Plot tokens ensure proper begin/end pairing
- RAII: Automatic cleanup of resources and style stacks
- Builder Patterns: Fluent APIs for configuration
- Modular Design: Each plot type is in its own module
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.