Overview of egui_plot
mainegui. It allows for high-performance, interactive 2D visualizations within the egui ecosystem.repository·main·Indexed 19 days ago
https://github.com/emilk/egui_plotAn immediate mode 2D plotting library for the egui framework in Rust, providing tools for interactive data visualization. It supports various plot items including lines, polygons, points, arrows, text, images, heatmaps, histograms, and box-and-whisker plots. Key features include performance optimizations via PlotPoints::Borrowed, custom axis formatting, linked axes for synchronized views, and the ability to export plots as PNG images.
egui. It allows for high-performance, interactive 2D visualizations within the egui ecosystem.The long-term goal of egui_plot is to support all matplotlib examples. Currently, several styles and pyplot functionalities are identified as missing or needing implementation. Developers looking to extend the library can refer to the following categories of missing features:
Support for various Matplotlib style sheets is currently missing, including:
bmh (Bayesian Methods for Hackers)dark_backgroundfivethirtyeightggplotgrayscalepetroff10solarized_lightKey functionalities from the Matplotlib pyplot module that are still being implemented include:
The long-term goal of egui_plot is to support all matplotlib examples. Currently, several interactive widgets and layout features found in Matplotlib are not yet implemented or fully supported in egui_plot.
Many interactive components are currently missing, including:
The long-term goal of egui_plot is to support all matplotlib examples. This means implementing missing features required to replicate the functionality found in various Matplotlib GUI embedding demos (such as GTK, Qt, Tk, and wx).
If you are looking for specific features that are currently missing or under development, you can track them via GitHub issue labels such as component: figure, component: interactivity, component: text, component: histogram, component: annotation, and component: spectral plot.
When creating plot lines in egui_plot, you can use PlotPoints::Borrowed to reference existing data instead of cloning it. This is a performance optimization that avoids unnecessary allocations, making it ideal for performance-critical applications or scenarios where the same data is reused across multiple frames.
Instead of passing owned data that requires a copy, you provide a reference to the data, allowing the plot to read directly from your existing buffers.
// Conceptual usage of Borrowed points to avoid cloning
let data: Vec<[f64; 2]> = get_large_dataset();
let points = PlotPoints::Borrowed(&data);
// Use points in your plot line creationmatplotlib examples. Currently, several features related to unit handling (such as annotations with units, radian ticks, and unit-aware bar charts) are missing in egui_plot. If you need specific unit-based plotting capabilities, check the existing issues tagged with component: units to see the current status of implementation.When deciding on a plotting library for Rust, egui_plot offers two primary advantages over the alternatives found in the ecosystem:
plotters) that require JavaScript or other binding layers for interactivity, egui_plot supports plot interactions directly through Rust.egui_plot produces a list of painting commands sent to a backend renderer. This allows for GPU acceleration and easy integration into other GUIs via egui, making it efficient for rendering large numbers of interactive plot items.egui_plot is to support all matplotlib examples. This serves as a roadmap for the library's feature development and capabilities.You can run the Legend Sort example either natively using Cargo or in a web browser using Trunk (WASM).
### Native
```sh
cargo run -p legend_sortcd examples/legend_sort
trunk serveThe Line Demo showcases line plotting features such as animated lines, various line styles (solid, dashed, dotted), gradients, fills, axis inversion, and coordinate display. You can run this example either natively or in a web browser via WASM.
### Native
```sh
cargo run -p linescd examples/lines
trunk serveThe Interaction Demo showcases how to interact with plots programmatically, including accessing plot bounds, pointer coordinates, drag deltas, and detecting hovered plot items. You can run this example as a native application or as a web application using WASM.
# Run as a native application
cargo run -p interaction
# Run as a web application (WASM)
cd examples/interaction
trunk serveThe Heatmap Demo showcases how to create animated heatmaps using egui_plot. It visualizes a 2D grid of values using color gradients (specifically the Turbo colormap) and allows for customizable dimensions, labels, and palettes.
To run the demo locally using Cargo:
cargo run -p heatmapTo run the demo in a web browser using WASM and Trunk:
cd examples/heatmap
trunk serve# Native execution
cargo run -p heatmap
# Web (WASM) execution
cd examples/heatmap
trunk serve