Crate dear_implot

Crate dear_implot 

Source
Expand description

§Dear ImPlot - Rust Bindings with Dear ImGui Compatibility

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
  • Full compatibility with dear-imgui
  • Builder pattern for plots and plot elements
  • Memory-safe string handling
  • Support for all major plot types

§Quick Start

use dear_imgui_rs::*;
use dear_implot::*;

let mut ctx = Context::create();
let mut plot_ctx = PlotContext::create(&ctx);

let ui = ctx.frame();
let plot_ui = plot_ctx.get_plot_ui(&ui);

if let Some(token) = plot_ui.begin_plot("My Plot") {
    plot_ui.plot_line("Line", &[1.0, 2.0, 3.0, 4.0], &[1.0, 4.0, 2.0, 3.0]);
    token.end();
}

§Integration with Dear ImGui

This crate is designed to work with the dear-imgui-rs ecosystem:

  • Uses the same context management patterns
  • Compatible with dear-imgui’s UI tokens and lifetime management
  • Shares the same underlying Dear ImGui context

Re-exports§

pub use plots::Plot;
pub use plots::PlotData;
pub use plots::PlotError;
pub use plots::bar::BarPlot;
pub use plots::bar::PositionalBarPlot;
pub use plots::error_bars::AsymmetricErrorBarsPlot;
pub use plots::error_bars::ErrorBarsPlot;
pub use plots::error_bars::SimpleErrorBarsPlot;
pub use plots::heatmap::HeatmapPlot;
pub use plots::heatmap::HeatmapPlotF32;
pub use plots::histogram::Histogram2DPlot;
pub use plots::histogram::HistogramPlot;
pub use plots::line::LinePlot;
pub use plots::line::SimpleLinePlot;
pub use plots::pie::PieChartPlot;
pub use plots::pie::PieChartPlotF32;
pub use plots::scatter::ScatterPlot;
pub use plots::scatter::SimpleScatterPlot;
pub use plots::shaded::ShadedBetweenPlot;
pub use plots::shaded::ShadedPlot;
pub use plots::shaded::SimpleShadedPlot;
pub use plots::stems::SimpleStemPlot;
pub use plots::stems::StemPlot;
pub use plots::*;

Modules§

plots
Modular plot types for ImPlot

Macros§

dummy_plots
Macro for creating multiple dummy plots easily
legend_group
Macro for creating a legend group
plot_text
Convenience macro for creating formatted text plots

Structs§

AxisFlags
Axis flags matching ImPlotAxisFlags_ (see cimplot.h)
AxisFormatterToken
AxisTransformToken
BarGroupsFlags
Flags for bar groups plots
BarsFlags
Flags for bar plots
Context
An imgui context.
DigitalFlags
Flags for digital plots
DragResult
Result of a drag interaction
DragToolFlags
Flags for drag tools (points/lines)
DummyFlags
Flags for dummy plots
ErrorBarsFlags
Flags for error bar plots
HeatmapFlags
Flags for heatmap plots
HistogramFlags
Flags for histogram plots
ImageFlags
Flags for image plots
InfLinesFlags
Flags for infinite lines plots
LegendFlags
Flags for legend configuration
LegendManager
Legend management utilities
LegendToken
Token representing an active legend
LineFlags
Flags for line plots
MultiAxisPlot
Multi-axis plot support
MultiAxisToken
Token representing an active multi-axis plot
PieChartFlags
Flags for pie chart plots
PlotContext
ImPlot context that manages the plotting state
PlotFlags
Flags for plot configuration
PlotToken
Token that represents an active plot
PlotUi
A temporary reference for building plots
ScatterFlags
Flags for scatter plots
ShadedFlags
Flags for shaded plots
StairsFlags
Flags for stairs plots
StemsFlags
Flags for stem plots
StyleColorToken
Token for managing style color changes
StyleVarToken
Token for managing style variable changes
SubplotFlags
Flags for subplot configuration
SubplotGrid
Multi-plot layout manager for creating subplot grids
SubplotToken
Token representing an active subplot grid
TextFlags
Flags for text plots
Ui
Represents the Dear ImGui user interface for one frame
YAxisConfig
Configuration for a Y-axis

Enums§

BinMethod
Binning methods for histograms
Colormap
Built-in colormaps
LegendLocation
Legend location options
Marker
Markers for plot points
PlotColorElement
Colorable plot elements
PlotCond
Plot condition (setup/next) matching ImPlotCond (ImGuiCond)
PlotLocation
Plot location for legends, labels, etc.
PlotOrientation
Plot orientation
StyleVar
Style variables that can be modified
XAxis
X axis selector matching ImPlot’s ImAxis values
YAxis
Y axis selector matching ImPlot’s ImAxis values
YAxisChoice
Choice of Y axis for multi-axis plots

Traits§

ImPlotExt
Ui extension for obtaining a PlotUi from an ImPlot PlotContext

Functions§

add_colormap
Add a custom colormap from a vector of colors
annotation_point
Draw a simple round annotation marker at (x,y)
colormap_button
Draw a colormap picker button; returns true if clicked
colormap_scale
Draw a colormap scale widget
colormap_slider
Draw a colormap slider; returns true if selection changed
drag_line_x
Draggable vertical line at x
drag_line_y
Draggable horizontal line at y
drag_point
Draggable point with result flags
get_plot_draw_list
Get the underlying ImDrawList for the current plot (unsafe pointer)
get_plot_limits
Get the current plot limits
get_plot_limits_axes
Get the current plot limits for specific axes
get_plot_mouse_position
Get the mouse position in plot coordinates
get_plot_mouse_position_axes
Get the mouse position in plot coordinates for specific axes
get_plot_pos
Get current plot position (top-left) in pixels
get_plot_selection_axes
Get the current plot selection rectangle for specific axes
get_plot_size
Get current plot size in pixels
is_axis_hovered
Check if an axis is hovered
is_legend_entry_hovered
Check if a legend entry is hovered
is_plot_hovered
Check if the plot area is hovered
is_plot_selected
Whether a plot has an active selection region
is_plot_x_axis_hovered
Check if the X axis is hovered
is_plot_x_axis_hovered_axis
Check if a specific X axis is hovered
is_plot_y_axis_hovered
Check if a Y axis is hovered
is_plot_y_axis_hovered_axis
Check if a specific Y axis is hovered
is_subplots_hovered
Check if any subplots area is hovered
map_input_default
Map input to defaults
map_input_reverse
Map input to reversed scheme
pixels_to_plot
Convert pixels to plot coordinates
pixels_to_plot_axes
Convert pixels to plot coordinates for specific axes
plot_to_pixels
Convert plot coordinates to pixels
plot_to_pixels_axes
Convert plot coordinates to pixels for specific axes
pop_colormap
Pop a colormap from the stack
pop_plot_clip_rect
Pop plot clip rect
push_colormap
Push a colormap to the stack
push_plot_clip_rect
Push plot clip rect
push_style_color
Push a style color to the stack
push_style_var_f32
Push a float style variable to the stack
push_style_var_i32
Push an integer style variable to the stack (converted to float)
push_style_var_vec2
Push a Vec2 style variable to the stack
show_colormap_selector
Show the ImPlot colormap selector combo; returns true if selection changed
show_demo_window
Stub when demo feature is disabled
show_input_map_selector
Show the ImPlot input-map selector combo; returns true if selection changed
show_metrics_window
Show the metrics window (pass &mut bool for open state)
show_style_editor
Show the ImPlot style editor window
show_style_selector
Show the ImPlot style selector combo; returns true if selection changed
show_user_guide
Show the built-in user guide for ImPlot
tag_x
Tag the X axis at position x with a tick-like mark
tag_y
Tag the Y axis at position y with a tick-like mark

Type Aliases§

ImPlotPoint
ImPlotRange
ImPlotRect
ImTextureID
ImVec2
ImVec4