All Projects → soulthreads → Imgui Plot

soulthreads / Imgui Plot

Licence: mit
An improved plot widget for Dear ImGui, aimed at displaying audio data

Projects that are alternatives of or similar to Imgui Plot

Implot
Immediate Mode Plotting
Stars: ✭ 2,014 (+506.63%)
Mutual labels:  gui, imgui, plot
Hello imgui
Hello, Dear ImGui: cross-platform Gui apps for Windows / Mac / Linux / iOS / Android / Emscripten with the simplicity of a "Hello World" app
Stars: ✭ 120 (-63.86%)
Mutual labels:  gui, imgui
Horus ui
HorusUI Immediate Mode Graphical User Interface
Stars: ✭ 106 (-68.07%)
Mutual labels:  gui, imgui
Imgui
Immediate Mode GUI for C#
Stars: ✭ 133 (-59.94%)
Mutual labels:  gui, imgui
Swiftgui
SwiftGUI is an API inspired by SwiftUI DSL, using Dear ImGui as renderer and running on macOS 10.13+ and iOS 11+
Stars: ✭ 74 (-77.71%)
Mutual labels:  gui, imgui
Imgui Rs
Rust bindings for Dear ImGui
Stars: ✭ 1,258 (+278.92%)
Mutual labels:  gui, imgui
Nukleardotnet
.NET binding for the Nuklear immediate mode GUI
Stars: ✭ 126 (-62.05%)
Mutual labels:  gui, imgui
Giu
Cross platform rapid GUI framework for golang based on Dear ImGui.
Stars: ✭ 862 (+159.64%)
Mutual labels:  gui, imgui
Bimpy
imgui for python
Stars: ✭ 144 (-56.63%)
Mutual labels:  gui, imgui
Rapidgui
Unity OnGUI(IMGUI) extensions for Rapid prototyping/development
Stars: ✭ 144 (-56.63%)
Mutual labels:  gui, imgui
Visbrain
A multi-purpose GPU-accelerated open-source suite for brain data visualization
Stars: ✭ 172 (-48.19%)
Mutual labels:  gui, plot
Asap app imgui
Starter project for portable app with optional GUI (GLFW/ImGui) and a rich builtin debug UI. Includes docked windows, log viewer, settings editor, configuration load/save, etc...
Stars: ✭ 70 (-78.92%)
Mutual labels:  gui, imgui
Wtk
📺 A cross-platform immediate mode user-interface library. Public domain.
Stars: ✭ 30 (-90.96%)
Mutual labels:  gui, imgui
Imgui
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
Stars: ✭ 33,574 (+10012.65%)
Mutual labels:  gui, imgui
Nuklear
A single-header ANSI C gui library
Stars: ✭ 13,365 (+3925.6%)
Mutual labels:  gui, imgui
Sonyheadphonesclient
A {Windows, macOS, Linux} client recreating the functionality of the Sony Headphones app
Stars: ✭ 123 (-62.95%)
Mutual labels:  gui, imgui
Cvui
A (very) simple UI lib built on top of OpenCV drawing primitives
Stars: ✭ 619 (+86.45%)
Mutual labels:  gui, imgui
Cimgui
c-api for imgui (https://github.com/ocornut/imgui) Look at: https://github.com/cimgui for other widgets
Stars: ✭ 707 (+112.95%)
Mutual labels:  gui, imgui
Imgui sdl
ImGuiSDL: SDL2 based renderer for Dear ImGui
Stars: ✭ 134 (-59.64%)
Mutual labels:  gui, imgui
Webgui
An example demo of IMGUI (Immediate Mode GUI) on the web. Using only WebGL, GLFW and ImGui. Suitable for being compiled to web assembly (WASM).
Stars: ✭ 180 (-45.78%)
Mutual labels:  gui, imgui

imgui-plot

An improved plot widget for Dear ImGui, aimed at displaying audio data

TOC

  1. Screenshots
  2. Rationale
  3. Usage
  4. Installation
  5. FAQ

Screenshots

Displaying waveform and spectrum:
Displaying Waveform and Spectrum

Custom tooltip:
Custom Tooltip

Selection example:
Selection Example

Rationale

The PlotLines() function in Dear ImGui is nice and simple, but it does lack some basic features, such as grids, logarithmic scaling, custom tooltips etc.

My work involves handling lots of waveforms and their spectrums, so I decided to extend PlotLines() with these features to display this data in a nice(r) way.

Usage

Instead of feeding all the parameters into plot function via its arguments, I decided that, with all the configurability, it would be cleaner to have a struct PlotConfig with all the neccessary stuff in it. See imgui_plot.h for its description.

Simple usecase:

ImGui::PlotConfig conf;
conf.values.xs = x_data; // this line is optional
conf.values.ys = y_data;
conf.values.count = data_count;
conf.scale.min = -1;
conf.scale.max = 1;
conf.tooltip.show = true;
conf.tooltip.format = "x=%.2f, y=%.2f";
conf.grid_x.show = true;
conf.grid_y.show = true;
conf.frame_size = ImVec2(400, 400);
conf.line_thickness = 2.f;

ImGui::Plot("plot", conf);

Selection example (gif above):

constexpr size_t buf_size = 512;
static float x_data[buf_size];
static float y_data1[buf_size];
static float y_data2[buf_size];
static float y_data3[buf_size];

void generate_data() {
    constexpr float sampling_freq = 44100;
    constexpr float freq = 500;
    for (size_t i = 0; i < buf_size; ++i) {
        const float t = i / sampling_freq;
        x_data[i] = t;
        const float arg = 2 * M_PI * freq * t;
        y_data1[i] = sin(arg);
        y_data2[i] = y_data1[i] * -0.6 + sin(2 * arg) * 0.4;
        y_data3[i] = y_data2[i] * -0.6 + sin(3 * arg) * 0.4;
    }
}

void draw_multi_plot() {
    static const float* y_data[] = { y_data1, y_data2, y_data3 };
    static ImU32 colors[3] = { ImColor(0, 255, 0), ImColor(255, 0, 0), ImColor(0, 0, 255) };
    static uint32_t selection_start = 0, selection_length = 0;

    ImGui::Begin("Example plot", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
    // Draw first plot with multiple sources
    ImGui::PlotConfig conf;
    conf.values.xs = x_data;
    conf.values.count = buf_size;
    conf.values.ys_list = y_data; // use ys_list to draw several lines simultaneously
    conf.values.ys_count = 3;
    conf.values.colors = colors;
    conf.scale.min = -1;
    conf.scale.max = 1;
    conf.tooltip.show = true;
    conf.grid_x.show = true;
    conf.grid_x.size = 128;
    conf.grid_x.subticks = 4;
    conf.grid_y.show = true;
    conf.grid_y.size = 0.5f;
    conf.grid_y.subticks = 5;
    conf.selection.show = true;
    conf.selection.start = &selection_start;
    conf.selection.length = &selection_length;
    conf.frame_size = ImVec2(buf_size, 200);
    ImGui::Plot("plot1", conf);

    // Draw second plot with the selection
    // reset previous values
    conf.values.ys_list = nullptr;
    conf.selection.show = false;
    // set new ones
    conf.values.ys = y_data3;
    conf.values.offset = selection_start;
    conf.values.count = selection_length;
    conf.line_thickness = 2.f;
    ImGui::Plot("plot2", conf);

    ImGui::End();
}

Installation

Just copy include/imgui_plot.h and src/imgui_plot.cpp to where your imgui is, and it should work like that.

CMake

Alternatively, you can use FetchContent like this:

include(FetchContent)
FetchContent_Declare(
    imgui_plot
    GIT_REPOSITORY https://github.com/soulthreads/imgui-plot.git
    GIT_TAG v0.1.0
    EXCLUDE_FROM_ALL
)
FetchContent_GetProperties(imgui_plot)
if(NOT imgui_plot_POPULATED)
    FetchContent_Populate(imgui_plot)
    add_subdirectory(${imgui_plot_SOURCE_DIR} ${imgui_plot_BINARY_DIR})
endif()

and then just link imgui_plot into your application. If you have ImGui located not in {repo}/imgui you can set IMGUI_INCLUDE_DIR variable to the according value.

FAQ

How do I do x?

If something isn't obvious or your think my design is bad, please file away an issue, I'll take a look at it.

If you want to have some new feature, issues and PRs are welcome too.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].