Add attribute-based legends (colorlegend, sizelegend, symbollegend) #7656
+4,590
−13
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.
Implementation for Issue #5099 ( #5099 ) adds three new legend components that show unique values from marker attributes (color, size, symbol) rather than trace-based legends.
New components:
Features:
Summary
This PR implements attribute-based legends as requested in #5099.
Currently, Plotly.js legends are trace-centric (one entry per trace), which becomes unwieldy when multiple traces share visual attributes like color scales or size mappings across hundreds of points. This enhancement adds three new legend components that allow users to create separate legends based on marker attributes:
colorlegend- Discrete color swatch legend for categorical or binned color valuessizelegend- Graduated circle legend for size rangessymbollegend- Symbol shape legend for marker symbolsNew Trace Attributes
marker.colorlegend- Reference tolayout.colorlegendmarker.sizelegend- Reference tolayout.sizelegendmarker.symbollegend- Reference tolayout.symbollegendExample Usage