{"id":13731982,"url":"https://github.com/soulthreads/imgui-plot","last_synced_at":"2025-05-08T06:31:03.003Z","repository":{"id":40432330,"uuid":"203788500","full_name":"soulthreads/imgui-plot","owner":"soulthreads","description":"An improved plot widget for Dear ImGui, aimed at displaying audio data","archived":true,"fork":false,"pushed_at":"2023-09-18T18:12:21.000Z","size":18,"stargazers_count":446,"open_issues_count":7,"forks_count":47,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-08-04T02:10:39.754Z","etag":null,"topics":["gui","imgui","plot"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulthreads.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-22T12:15:47.000Z","updated_at":"2024-06-30T16:28:33.000Z","dependencies_parsed_at":"2022-08-20T01:01:41.480Z","dependency_job_id":null,"html_url":"https://github.com/soulthreads/imgui-plot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulthreads%2Fimgui-plot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulthreads%2Fimgui-plot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulthreads%2Fimgui-plot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulthreads%2Fimgui-plot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulthreads","download_url":"https://codeload.github.com/soulthreads/imgui-plot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224707578,"owners_count":17356360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gui","imgui","plot"],"created_at":"2024-08-03T02:01:43.051Z","updated_at":"2024-11-14T23:30:43.990Z","avatar_url":"https://github.com/soulthreads.png","language":"C++","readme":"# imgui-plot\nAn improved plot widget for [Dear ImGui](https://github.com/ocornut/imgui/), aimed at displaying audio data\n\n## TOC\n1. [Screenshots](#screenshots)\n2. [Rationale](#rationale)\n3. [Usage](#usage)\n4. [Installation](#installation)\n5. [FAQ](#faq)\n\n## Screenshots\nDisplaying waveform and spectrum:  \n![Displaying Waveform and Spectrum](https://linuxoids.net/static/imgui-plot/waveform_and_spectrum.png)\n\nCustom tooltip:  \n![Custom Tooltip](https://linuxoids.net/static/imgui-plot/custom_tooltip.png)\n\nSelection example:  \n![Selection Example](https://linuxoids.net/static/imgui-plot/selection_example.gif)\n\n## Rationale\nThe `PlotLines()` function in Dear ImGui is nice and simple, but it does lack some basic features, such as grids, logarithmic scaling, custom tooltips etc.\n\nMy 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.\n\n## Usage\nInstead 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.\n\nSimple usecase:\n```cpp\nImGui::PlotConfig conf;\nconf.values.xs = x_data; // this line is optional\nconf.values.ys = y_data;\nconf.values.count = data_count;\nconf.scale.min = -1;\nconf.scale.max = 1;\nconf.tooltip.show = true;\nconf.tooltip.format = \"x=%.2f, y=%.2f\";\nconf.grid_x.show = true;\nconf.grid_y.show = true;\nconf.frame_size = ImVec2(400, 400);\nconf.line_thickness = 2.f;\n\nImGui::Plot(\"plot\", conf);\n```\n\nSelection example (gif above):\n```cpp\nconstexpr size_t buf_size = 512;\nstatic float x_data[buf_size];\nstatic float y_data1[buf_size];\nstatic float y_data2[buf_size];\nstatic float y_data3[buf_size];\n\nvoid generate_data() {\n    constexpr float sampling_freq = 44100;\n    constexpr float freq = 500;\n    for (size_t i = 0; i \u003c buf_size; ++i) {\n        const float t = i / sampling_freq;\n        x_data[i] = t;\n        const float arg = 2 * M_PI * freq * t;\n        y_data1[i] = sin(arg);\n        y_data2[i] = y_data1[i] * -0.6 + sin(2 * arg) * 0.4;\n        y_data3[i] = y_data2[i] * -0.6 + sin(3 * arg) * 0.4;\n    }\n}\n\nvoid draw_multi_plot() {\n    static const float* y_data[] = { y_data1, y_data2, y_data3 };\n    static ImU32 colors[3] = { ImColor(0, 255, 0), ImColor(255, 0, 0), ImColor(0, 0, 255) };\n    static uint32_t selection_start = 0, selection_length = 0;\n\n    ImGui::Begin(\"Example plot\", nullptr, ImGuiWindowFlags_AlwaysAutoResize);\n    // Draw first plot with multiple sources\n    ImGui::PlotConfig conf;\n    conf.values.xs = x_data;\n    conf.values.count = buf_size;\n    conf.values.ys_list = y_data; // use ys_list to draw several lines simultaneously\n    conf.values.ys_count = 3;\n    conf.values.colors = colors;\n    conf.scale.min = -1;\n    conf.scale.max = 1;\n    conf.tooltip.show = true;\n    conf.grid_x.show = true;\n    conf.grid_x.size = 128;\n    conf.grid_x.subticks = 4;\n    conf.grid_y.show = true;\n    conf.grid_y.size = 0.5f;\n    conf.grid_y.subticks = 5;\n    conf.selection.show = true;\n    conf.selection.start = \u0026selection_start;\n    conf.selection.length = \u0026selection_length;\n    conf.frame_size = ImVec2(buf_size, 200);\n    ImGui::Plot(\"plot1\", conf);\n\n    // Draw second plot with the selection\n    // reset previous values\n    conf.values.ys_list = nullptr;\n    conf.selection.show = false;\n    // set new ones\n    conf.values.ys = y_data3;\n    conf.values.offset = selection_start;\n    conf.values.count = selection_length;\n    conf.line_thickness = 2.f;\n    ImGui::Plot(\"plot2\", conf);\n\n    ImGui::End();\n}\n\n```\n\n## Installation\nJust copy `include/imgui_plot.h` and `src/imgui_plot.cpp` to where your imgui is, and it should work like that.\n\n### CMake\nAlternatively, you can use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) like this:\n\n```cmake\ninclude(FetchContent)\n# Optional: Set IMGUI_INCLUDE_DIR to the path of imgui sources, if different from the default. \n# set(IMGUI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/imgui)\nFetchContent_Declare(\n    imgui_plot\n    GIT_REPOSITORY https://github.com/soulthreads/imgui-plot.git\n    GIT_TAG v0.1.0\n    EXCLUDE_FROM_ALL\n)\nFetchContent_MakeAvailable(imgui_plot)\n# ...\ntarget_link_libraries(${PROJECT_NAME} PRIVATE imgui_plot)\n```\n\n## FAQ\n### How do I do _x_?\nIf something isn't obvious or your think my design is bad, please file away an issue, I'll take a look at it.\n\nIf you want to have some new feature, issues and PRs are welcome too.\n","funding_links":[],"categories":["Graphics"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulthreads%2Fimgui-plot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulthreads%2Fimgui-plot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulthreads%2Fimgui-plot/lists"}