question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single-toggle of grouped traces in legend

See original GitHub issue

This 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.

Related: #65, #665, #674

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
rithwikjccommented, Jun 9, 2021

I would summarize the suggestions as follows.

  • It would help to have a legend group title for each legend group. Clicking on it can act as toggle for all scatters of that legend group. This also takes care of #689.
  • Each individual scatter is grouped under it’s respective legend group title, and the toggle for each scatter works as it usually does for the individual scatters.
  • Legend groups can be toggled by something like legend_legendgrouptitles in layout (this is global, meaning all legend group names are displayed or hidden for the particular plot), and each scatter is handled already as done by showlegend 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: NewLegend

3reactions
mcstarionicommented, May 6, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found