Skip to content

Feat: Different types of legend icon#680

Open
brenocq wants to merge 1 commit intomasterfrom
feat/improve-legend-icons
Open

Feat: Different types of legend icon#680
brenocq wants to merge 1 commit intomasterfrom
feat/improve-legend-icons

Conversation

@brenocq
Copy link
Copy Markdown
Collaborator

@brenocq brenocq commented Feb 17, 2026

Closes #569
Closes #160

Image Image

Image Image

Improved Legend Icons

Summary

Legend icons now accurately represent the plot type instead of always showing a solid square.

Changes

  • Line plots: Display as horizontal lines in legend
  • Line plots with markers: Display as horizontal line with centered marker
  • Scatter plots: Display as single marker (no line)
  • Filled plots (shaded, pie, heatmap, digital): Display as filled square
  • Bar plots/histograms: Display as filled square with outline

Implementation

  • Added ImPlotLegendIconType_ enum with 5 icon types: Line, LineMarkers, Markers, Fill, FillLine
  • Extended ImPlotItem to store legend rendering data (colors, marker type, line weight, icon type)
  • Added RenderLegendIcon() to render icons based on type
  • Each plot function explicitly sets its icon type when calling BeginItem()
  • Markers in legend are consistently sized at 0.5× icon width

Technical Details

  • Icon type is determined per-plot-type
  • Legend icons respect the same color properties as the plot (line color, fill color, marker colors)
  • Icons respond to hover/held/disabled states with alpha modulation
  • No breaking changes to public API

@brenocq brenocq self-assigned this Feb 17, 2026
@brenocq brenocq added type:feat New feature or request prio:high High priority status:review The task is under review labels Feb 17, 2026
@janarombe
Copy link
Copy Markdown

Isn't there a problem in the "Stairstep Plot" picture above? The "Post Step (default)" legend item shows a blue square, but in the curve, the markers look like circles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:high High priority status:review The task is under review type:feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

marker shapes in legend Legend enhancement

2 participants