Feat: Per-Index Color/Size Support with ImPlotSpec#672
Merged
Conversation
This was referenced Feb 14, 2026
|
This is amazing update. The implementation looks nice and easy to use. Since ImPlot has contained many kind of beautiful plots, the next object for development might be exporting the plots to high-resolution images, which could be used in papers and reports. |
8 tasks
This was referenced Apr 4, 2026
phraktle
added a commit
to phraktle/imgui-java
that referenced
this pull request
Apr 19, 2026
…otSpec Upstream implot v1.0 (https://github.com/epezent/implot/releases/tag/v1.0) is a breaking release that replaces per-call (flags, offset, stride) args on every Plot* function with a single ImPlotSpec value-type, and removes the SetNextX-style helpers. The headline new feature is per-index colors and marker sizes via ImPlotSpec arrays (PR epezent/implot#672). Binding changes: - Advance include/implot submodule 1f7a8c0 -> v1.0 (524f9fc) - Regenerate ast-implot.json - Add ImPlotSpec: scalar @BindingField props plus hand-written native setters for the 5 array-pointer fields (LineColors, FillColors, MarkerSizes, MarkerLineColors, MarkerFillColors). Backing buffers are owned in native memory (ImGui::MemAlloc) and freed on destroy() or on reassignment. - Rewrite every Plot* signature: the (flags, offset, stride) tail is replaced by `@OptArg @ArgValue(callPrefix="*") ImPlotSpec spec`, which marshals to `*reinterpret_cast<ImPlotSpec*>(spec.ptr)` at the C++ call site. Progressive-cutoff overloads still expose spec-less variants (relying on C++ default `= ImPlotSpec()`). - Add PlotPolygon, PlotBubbles, NextMarker (new in v1.0) - Remove SetNextLineStyle / SetNextFillStyle / SetNextMarkerStyle / SetNextErrorBarStyle (obsoleted in v1.0 -- configure ImPlotSpec instead) - Trim ImPlotStyle: drop LineWeight/Marker/MarkerSize/MarkerWeight/ FillAlpha/ErrorBarSize/ErrorBarWeight/DigitalBitHeight/ DigitalBitGap (all moved into ImPlotSpec); add new DigitalPadding/DigitalSpacing - Flag enums shift accordingly: ImPlotMarker_None is now -2 (ImPlotMarker_Auto = -1 is new); ImPlotCol drops the 5 per-item entries (Line/Fill/MarkerOutline/MarkerFill/ErrorBar); ImPlotStyleVar drops the 9 matching vars; ImPlotLegendFlags gains Reverse; ImPlotPieChartFlags gains Exploding + NoSliceBorder; new ImPlotBubblesFlags / ImPlotPolygonFlags enums are AST-driven. Example: ExampleImPlot grows a "Per-Index Colors (v1.0 PR #672)" plot showing rainbow LineColors + MarkerFillColors + ramping MarkerSizes. Note: this is source-incompatible for any caller of the affected Plot* methods or the removed SetNextX helpers. The incompatibility mirrors upstream implot's own v1.0 break and is the minimum footprint to expose the new ImPlotSpec-based API. Dear ImGui submodule is intentionally left at v1.90.9-docking. implot v1.0 guards its 1.92-era uses (ImTextureRef, ImFontBaked, CalcFontSize) behind `#ifdef IMGUI_HAS_TEXTURES` / `IMGUI_VERSION_NUM` and compiles cleanly against 1.90.9. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
phraktle
added a commit
to phraktle/imgui-java
that referenced
this pull request
Apr 21, 2026
…otSpec Upstream implot v1.0 (https://github.com/epezent/implot/releases/tag/v1.0) is a breaking release that replaces per-call (flags, offset, stride) args on every Plot* function with a single ImPlotSpec value-type, and removes the SetNextX-style helpers. The headline new feature is per-index colors and marker sizes via ImPlotSpec arrays (PR epezent/implot#672). Binding changes: - Advance include/implot submodule 1f7a8c0 -> v1.0 (524f9fc) - Regenerate ast-implot.json - Add ImPlotSpec: scalar @BindingField props plus hand-written native setters for the 5 array-pointer fields (LineColors, FillColors, MarkerSizes, MarkerLineColors, MarkerFillColors). Backing buffers are owned in native memory (ImGui::MemAlloc) and freed on destroy() or on reassignment. - Rewrite every Plot* signature: the (flags, offset, stride) tail is replaced by `@OptArg @ArgValue(callPrefix="*") ImPlotSpec spec`, which marshals to `*reinterpret_cast<ImPlotSpec*>(spec.ptr)` at the C++ call site. Progressive-cutoff overloads still expose spec-less variants (relying on C++ default `= ImPlotSpec()`). - Add PlotPolygon, PlotBubbles, NextMarker (new in v1.0) - Remove SetNextLineStyle / SetNextFillStyle / SetNextMarkerStyle / SetNextErrorBarStyle (obsoleted in v1.0 -- configure ImPlotSpec instead) - Trim ImPlotStyle: drop LineWeight/Marker/MarkerSize/MarkerWeight/ FillAlpha/ErrorBarSize/ErrorBarWeight/DigitalBitHeight/ DigitalBitGap (all moved into ImPlotSpec); add new DigitalPadding/DigitalSpacing - Flag enums shift accordingly: ImPlotMarker_None is now -2 (ImPlotMarker_Auto = -1 is new); ImPlotCol drops the 5 per-item entries (Line/Fill/MarkerOutline/MarkerFill/ErrorBar); ImPlotStyleVar drops the 9 matching vars; ImPlotLegendFlags gains Reverse; ImPlotPieChartFlags gains Exploding + NoSliceBorder; new ImPlotBubblesFlags / ImPlotPolygonFlags enums are AST-driven. Example: ExampleImPlot grows a "Per-Index Colors (v1.0 PR #672)" plot showing rainbow LineColors + MarkerFillColors + ramping MarkerSizes. Note: this is source-incompatible for any caller of the affected Plot* methods or the removed SetNextX helpers. The incompatibility mirrors upstream implot's own v1.0 break and is the minimum footprint to expose the new ImPlotSpec-based API. Dear ImGui submodule is intentionally left at v1.90.9-docking. implot v1.0 guards its 1.92-era uses (ImTextureRef, ImFontBaked, CalcFontSize) behind `#ifdef IMGUI_HAS_TEXTURES` / `IMGUI_VERSION_NUM` and compiles cleanly against 1.90.9. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SpaiR
pushed a commit
to SpaiR/imgui-java
that referenced
this pull request
Apr 21, 2026
* feat(api): bump ImPlot from 2023-era 1f7a8c0 to v1.0; migrate to ImPlotSpec Upstream implot v1.0 (https://github.com/epezent/implot/releases/tag/v1.0) is a breaking release that replaces per-call (flags, offset, stride) args on every Plot* function with a single ImPlotSpec value-type, and removes the SetNextX-style helpers. The headline new feature is per-index colors and marker sizes via ImPlotSpec arrays (PR epezent/implot#672). Binding changes: - Advance include/implot submodule 1f7a8c0 -> v1.0 (524f9fc) - Regenerate ast-implot.json - Add ImPlotSpec: scalar @BindingField props plus hand-written native setters for the 5 array-pointer fields (LineColors, FillColors, MarkerSizes, MarkerLineColors, MarkerFillColors). Backing buffers are owned in native memory (ImGui::MemAlloc) and freed on destroy() or on reassignment. - Rewrite every Plot* signature: the (flags, offset, stride) tail is replaced by `@OptArg @ArgValue(callPrefix="*") ImPlotSpec spec`, which marshals to `*reinterpret_cast<ImPlotSpec*>(spec.ptr)` at the C++ call site. Progressive-cutoff overloads still expose spec-less variants (relying on C++ default `= ImPlotSpec()`). - Add PlotPolygon, PlotBubbles, NextMarker (new in v1.0) - Remove SetNextLineStyle / SetNextFillStyle / SetNextMarkerStyle / SetNextErrorBarStyle (obsoleted in v1.0 -- configure ImPlotSpec instead) - Trim ImPlotStyle: drop LineWeight/Marker/MarkerSize/MarkerWeight/ FillAlpha/ErrorBarSize/ErrorBarWeight/DigitalBitHeight/ DigitalBitGap (all moved into ImPlotSpec); add new DigitalPadding/DigitalSpacing - Flag enums shift accordingly: ImPlotMarker_None is now -2 (ImPlotMarker_Auto = -1 is new); ImPlotCol drops the 5 per-item entries (Line/Fill/MarkerOutline/MarkerFill/ErrorBar); ImPlotStyleVar drops the 9 matching vars; ImPlotLegendFlags gains Reverse; ImPlotPieChartFlags gains Exploding + NoSliceBorder; new ImPlotBubblesFlags / ImPlotPolygonFlags enums are AST-driven. Example: ExampleImPlot grows a "Per-Index Colors (v1.0 PR #672)" plot showing rainbow LineColors + MarkerFillColors + ramping MarkerSizes. Note: this is source-incompatible for any caller of the affected Plot* methods or the removed SetNextX helpers. The incompatibility mirrors upstream implot's own v1.0 break and is the minimum footprint to expose the new ImPlotSpec-based API. Dear ImGui submodule is intentionally left at v1.90.9-docking. implot v1.0 guards its 1.92-era uses (ImTextureRef, ImFontBaked, CalcFontSize) behind `#ifdef IMGUI_HAS_TEXTURES` / `IMGUI_VERSION_NUM` and compiles cleanly against 1.90.9. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(implot): add length-aware overloads for ImPlotSpec array setters Mirror the convention used by plot methods (plotStairsV, plotScatterV, etc.) which accept a separate length parameter, letting callers pass a backing array larger than the logical count without having to Arrays.copyOf to an exactly-sized array per frame. Added (arr, len) overloads to: setLineColors setFillColors setMarkerSizes setMarkerLineColors setMarkerFillColors Motivation: when plotting bubble markers with per-point sizes that change every frame (trade prints, live signals), the existing setMarkerSizes(float[]) required an exactly-sized array each call, defeating any attempt to reuse a growing scratch buffer. The new overload lets callers keep a single float[] sized to capacity and pass the current logical length. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #485
Closes #298
Per-Index Color/Size Support with ImPlotSpec
Summary
This PR introduces comprehensive per-index color support across all ImPlot plot types. Users can now specify an array of colors to apply different colors to each vertex, segment, bar, marker, or other primitive in their plots, enabling rich data visualizations with color-coded information.
This implementation is based on previous work #332 by @niavok, #665 by @vincentjzy, and #608 by @mihaly-sisak.
Features
New Properties
Four new
ImPlotSpecproperties have been added to enable per-index coloring:ImPlotProp_LineColors- Array ofImU32colors for line segments/verticesImPlotProp_FillColors- Array ofImU32colors for filled regionsImPlotProp_MarkerLineColors- Array ofImU32colors for marker outlinesImPlotProp_MarkerFillColors- Array ofImU32colors for marker fillsImPlotProp_MarkerSizes- Array offloatfor marker sizesSupported Plot Types
Per-index colors are now supported in:
PlotLine)PlotShaded)PlotScatter)PlotBubbles)PlotBars)PlotStairs)PlotStems)PlotInfLines)Usage Example
Constant Color (Existing Behavior)
The existing single-color properties continue to work as before:
Per-Index Colors (New Feature)
To use per-index colors, provide an array of
ImU32colors:Scatter Plot with Per-Marker Colors/Sizes
Bar Plot with Per-Bar Colors
Implementation Details
Color Getter Architecture
The implementation uses a template-based color getter system:
GetterConstColor- Returns a constant color for all indices (used when single color is specified)GetterIdxColor- Returns per-index colors from an array (used when color array is specified)Both getters support alpha blending via a constructor parameter.
Backward Compatibility
All existing code continues to work without modification. The new per-index color properties are optional and only used when explicitly provided. When not specified, plots use the existing single-color properties (
ImPlotProp_LineColor,ImPlotProp_FillColor, etc.).Demo
A comprehensive "Per-Index Colors" demo has been added to
implot_demo.cppshowcasing:Run the demo to see all the colorful plot examples in action!
Testing
Notes
ImU32(useImGui::GetColorU32()orImColorto convert fromImVec4)FillAlphaproperty when applicable