You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importplotly.graph_objectsasgofig=go.Figure()
fig.add_shape(
type="line",
xref="x",
yref="y",
x0=4,
y0=0,
x1=8,
y1=1,
line=dict(
color="LightSeaGreen",
width=3,
),
legendgroup="group", # this can be any string, not just "group"name="first legend group",
showlegend=True,
)
fig.add_shape(
type="line",
xref="paper",
yref="paper",
x0=0,
y0=0,
x1=0.5,
y1=0.5,
line=dict(
color="DarkOrange",
width=3,
),
legendgroup="group", # this can be any string, not just "group"name="first legend group B",
showlegend=False,
)
fig.show()
importplotly.graph_objectsasgofig=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"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"),
showlegend=False,
))
fig.add_trace(go.Scatter(
x=[1, 2, 3],
y=[4, 9, 2],
legendgroup="group2",
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"),
showlegend=False
))
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
fig.show()
The text was updated successfully, but these errors were encountered:
Honghe
changed the title
Can't hide all shape entries in a group by its legend.
Bug: Can't hide all shape entries in a group by its legend.
Nov 22, 2024
Envivonment:
Bug recording:
Video.mp4
Bug code:
Reference:
https://plotly.com/python/legend/#grouped-legend-items Says: You can also hide entries in grouped legends, preserving the grouped show/hide behaviour. This is what Plotly Express does with its legends.
Excepted(The demo in the document):
Video.mp4
The demo Code in the document:
The text was updated successfully, but these errors were encountered: