1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-22 18:28:53 -05:00
A fork of implot, a plugin for the DearImGui framework which provides advanced data visualization features
Go to file
2020-04-27 23:57:57 -05:00
.gitignore Initial commit 2020-04-21 07:59:38 -05:00
implot_demo.cpp add plot queries, improve box selection controls with modifiers 2020-04-27 23:57:49 -05:00
implot.cpp add plot queries, improve box selection controls with modifiers 2020-04-27 23:57:49 -05:00
implot.h add plot queries, improve box selection controls with modifiers 2020-04-27 23:57:49 -05:00
LICENSE Initial commit 2020-04-21 07:59:38 -05:00
README.md Update README.md 2020-04-27 20:02:49 -05:00

ImPlot

ImPlot is an immediate mode plotting widget for Dear 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. Just like ImGui, it does not burden the end user with GUI state managment, avoids STL containers and C++ headers, and has no external dependencies except for ImGui itself.

Features

  • multiple plot types: line, scatter, vertical/horizontal bars, error bars, with more likely to come
  • mix/match multiple plot items on a single plot
  • configurable axes ranges and scaling (linear/log)
  • reversible and lockable axes
  • controls for zooming, panning, box selection, and auto-fitting data
  • 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
  • optional legend with toggle buttons to quickly show/hide items
  • 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)
  • relatively good performance for high density plots

Usage

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!

if (ImGui::BeginPlot("My Plot")) {
    ImGui::Plot("My Line Plot", x_data, y_data, 1000);
    ImGui::PlotBar("My Bar Plot", values, 10);
    ...
    ImGui::EndPlot();
}

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.

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.