1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 15:47:26 -04:00
implot/README.md

55 lines
3.8 KiB
Markdown
Raw Normal View History

2020-04-24 17:56:10 -04:00
# ImPlot
2020-04-26 18:37:57 -04:00
ImPlot is an immediate mode plotting widget for [Dear ImGui](https://github.com/ocornut/imgui). It aims to provide a first-class API that will make ImGui users feel right at home. ImPlot is well suited for visualizing program data in real-time and requires minimal code to integrate. Like ImGui, it does not use any C++11 features, headers, or STL containers, and has no external dependencies except for ImGui itself.
2020-04-24 17:56:10 -04:00
2020-04-25 10:02:51 -04:00
## Features
2020-04-24 17:56:10 -04:00
2020-04-27 11:46:06 -04:00
- multiple plot types: line, scatter, vertical/horizontal bars, error bars, with more likely to come
2020-04-25 10:02:51 -04:00
- mix/match multiple plot items on a single plot
2020-04-26 18:37:57 -04:00
- configurable axes ranges and scaling (linear/log)
- reversible and lockable axes
- controls for zooming, panning, box selection, and auto-fitting data
2020-04-25 10:02:51 -04:00
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
- optional plot titles, axis labels, and grid labels
2020-04-26 18:37:57 -04:00
- optional legend with toggle buttons to quickly show/hide items
2020-04-26 18:13:22 -04:00
- size-aware grid with smart labels that are always power-of-ten multiples of 1, 2, and 5
- default styling based on current ImGui theme, but most elements can be customized independently
- mouse cursor location display and optional crosshairs cursor
- customizable data getters and data striding (just like ImGui:PlotLines)
2020-04-25 10:02:51 -04:00
- relatively good performance for high density plots
2020-04-24 17:56:10 -04:00
2020-04-25 10:02:51 -04:00
## Usage
2020-04-26 18:13:22 -04:00
The API is used just like any other ImGui `Begin`/`End` function. First, start a plotting context with `BeginPlot()`. Next, plot as many items as you want with the provided API functions (e.g. `Plot()`, `PlotBar()`, `PlotErrorBars()`, etc). Finally, wrap things up with a call to `EndPlot()`. That's it!
2020-04-25 10:02:51 -04:00
```cpp
if (ImGui::BeginPlot("My Plot") {
2020-04-26 18:13:22 -04:00
ImGui::Plot("My Line Plot", xs ys, 1000);
ImGui::PlotBar("My Bar Plot", values, 20);
...
2020-04-25 10:02:51 -04:00
ImGui::EndPlot();
}
```
2020-04-26 18:37:57 -04:00
Consult `implot_demo.cpp` for a comprehensive example of ImPlot's features.
## Integration
Just add `implot.h`, `implot.cpp`, and optionally `implot_demo.cpp` to your sources. This assumes you already have an ImGui-ready environment. If not, consider trying [mahi-gui], which bundles ImGui, ImPlot, and several other packages for you.
2020-04-26 18:13:22 -04:00
2020-04-25 10:02:51 -04:00
## Special Notes
- By default, no anti-aliasing is done on line plots for performance reasons. My apps use 4X MSAA, so I didn't see any reason to waste cycles on software AA. However, you can enable AA with the `ImPlotFlags_AntiAliased` flag.
- If you plan to render several thousands lines or points, then you should consider enabling 32-bit indices by uncommenting `#define ImDrawIdx unsigned int` in your `imconfig.h` file, OR handling the `ImGuiBackendFlags_RendererHasVtxOffset` flag in your renderer (the official OpenGL3 renderer supports this). If you fail to do this, then you may at some point hit the maximum number of indices that can be rendered.
## Known Issues (Fix Me!)
2020-04-24 17:56:10 -04:00
2020-04-25 09:47:54 -04:00
- Zooming to a range beyond the limits of `FLT_MAX` and `FLT_MIN` causes axes labels to disappear.
2020-04-26 18:37:57 -04:00
## Gallery
2020-04-27 11:46:06 -04:00
2020-04-27 18:03:08 -04:00
<img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/zoom_pan.gif" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/controls.gif" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/dnd.gif" width="285">
2020-04-27 18:02:11 -04:00
2020-04-27 18:03:08 -04:00
<img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/line_plot.png" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/scatter_plot.png" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/bar_plot.png" width="285">
2020-04-27 18:02:11 -04:00
2020-04-27 18:03:08 -04:00
<img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/log_plot.png" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/error_bars.png" width="285"> <img src="https://raw.githubusercontent.com/wiki/epezent/implot/screenshots/markers.png" width="285">
2020-04-27 18:02:11 -04:00