Closed
Description
Adding fig.update_layout(legend_groupclick="toggleitem")
(as documented) to the grouped legend items example does not affect legend click behavior. With or without setting to "toggleitem"
, the whole group is toggled when clicking any item in the legend. Using plotly==5.4.0
.
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=[1, 2, 3],
y=[2, 1, 3],
legendgroup="group", # this can be any string, not just "group"
legendgrouptitle_text="First Group Title",
name="first legend group",
mode="markers",
marker=dict(color="Crimson", size=10),
)
)
fig.add_trace(
go.Scatter(
x=[1, 2, 3],
y=[2, 2, 2],
legendgroup="group",
name="first legend group - average",
mode="lines",
line=dict(color="Crimson"),
)
)
fig.add_trace(
go.Scatter(
x=[1, 2, 3],
y=[4, 9, 2],
legendgroup="group2",
legendgrouptitle_text="Second Group Title",
name="second legend group",
mode="markers",
marker=dict(color="MediumPurple", size=10),
)
)
fig.add_trace(
go.Scatter(
x=[1, 2, 3],
y=[5, 5, 5],
legendgroup="group2",
name="second legend group - average",
mode="lines",
line=dict(color="MediumPurple"),
)
)
# No effect from this line
fig.update_layout(legend_groupclick="toggleitem")
Metadata
Metadata
Assignees
Labels
No labels