Skip to content

Feature: legendgroup property should accept array to have multiple groups. #3076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ievgennaida opened this issue Feb 17, 2021 · 3 comments
Closed

Comments

@ievgennaida
Copy link

ievgennaida commented Feb 17, 2021

I would like to have legends grouped by a few criteria, ex: age, and gender.
Now it's possible to add a subgroups legend only by adding fake traces:

(comes from some plotly documentation)

fig.add_trace(go.Scatter(y=[None], mode='markers',
                         marker=dict(symbol='circle', color='black'),
                         name='Female',
                         ))

Only the gap that grouping is not working when legend is clicked from the frontend.
It would be possible to make it happened if the legendgroup property for each trace will accept an array.
In this case, it will be possible to still keep it clickable and resolve traces visibility.

Some related topics:
https://plotly.com/python/reference/#scatter-legendgroup
https://community.plotly.com/t/possible-to-have-nested-or-hierarchical-legends/2376/3
https://community.plotly.com/t/plotly-express-how-to-separate-symbol-and-color-in-legend/38950

@nicolaskruchten
Copy link
Contributor

Per-attribute legends are definitely something we want to support, although doing it via legendgroup is probably not the API we will end up with. Support for this will have to be added to Plotly.js first, and here is the issue tracking this: plotly/plotly.js#5099 ... right now there's no one working on it for lack of funding :)

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

@ievgennaida
Copy link
Author

For a people who are searching for the workaround: You can add traces in the specific order and also revert/control legends order .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants