Possible to have nested (or hierarchical) legends?

This is what I would think “legend groups” are for, but by the examples, does not seem to do what I want. I would like to be able to have something like this for plots that say have 4 traces, with two in one category and two in another. The categories would be the same color.

Women
—*--- Age 10-30
—±-- Age 30-60
Men
—o--- Age 10-30
#--- AGe 30-60

3 Likes

Hi there,
Nested legends aren’t possible at the moment.
Legend groups currently available in Plotly are for grouping traces so you can toggle groups of traces on/off at once (https://plot.ly/python/reference/#scatter-legendgroup).

Thanks Chelsea! I was trying to understand the value of legend groups–at first glance seemed to be just another way to set line style. But the toggle thing is really nice.

1 Like

@maxpuff it is under Grouped Legend here https://plot.ly/python/legend/

Any news on this ?

Any news on this 2024? I am looking for assigning one subplot to multiple legend groups for multiple filtering.

Check the curveNumber value passed in the plotly_legendclick event to know whether to hide the group or just the trace