Single-toggle of grouped traces in legend
See original GitHub issueThis is a feature request.
Please see default “Grouped Legend” example: https://codepen.io/plotly/pen/qjmNXa
Current behavior
It is possible to toggle single traces by clicking on them in the legend. If traces are grouped using legendgroup
(like in the example above) not the single traces but the whole group is toggled.
Future behavior
It should be possible to disable the toggling of the whole group and instead toggle the single traces like in no-grouped legends. This would make it possible in the example above to only disable the “points” and only show the “avarage line” of this group.
This should be done by a new option in the legend-settings.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Plotly: How to toggle traces with a button similar to clicking ...
The goal is to be able toggle everything (or a select group) to invisible but add individual items from that group back to...
Read more >Legends in Python - Plotly
Grouping legend items together by setting the legendgroup attribute of traces causes their legend entries to be next to each other, and clicking...
Read more >plotly.graph_objects.Indicator — 5.11.0 documentation
The trace name appear as the legend item and on hover. ... A single toggle to hide the axis while preserving interaction like...
Read more >plotly.graph_objs.layout - Anvil Docs
Legend plotly.graph_objs.layout. ... If *grouped*, the items are displayed in groups (when a trace `legendgroup` is provided). if *grouped+reversed*, ...
Read more >`legend_groupclick = "toggleitem"` doesn't seem to work in ...
Currently legend_groupclick="toggleitem" doesn't seem to work as can be tested in the result of using PlotlyJS function getData() x ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would summarize the suggestions as follows.
legend_legendgrouptitles
inlayout
(this is global, meaning all legend group names are displayed or hidden for the particular plot), and each scatter is handled already as done byshowlegend
parameter of the scatter.This solution should take care of most use cases and issues relating to legend group title and (scatter/group) toggles, except for the very particular use cases like selectively displaying legend group titles for certain legend groups.
The legend would look like this after such a change:
I would suggest a following behaviour: legend group would become an independent toggle with a name of a legendgroup, which would activate/deactivate all contained traces. Yet if someone needs to toggle some particular trace, he can add
showlegend=True
, and displayed legend for this trace would toggle only this trace.