Skip to content

fig.add_vrect() items do not hide when clicking on grouped legend if showlegend=False #4705

Description

@pcubillos

Hi,

Here's a reproducible example below. Clicking on the legend group does not hide the second vrect (unlike for fig.add_trace(go.Scatter()) calls). I tried it on versions 5.23.0 and 5.19.0.

import plotly.graph_objects as go

fig = go.Figure()

fig.add_vrect(
    x0=1.0, x1=3.0,
    fillcolor="LightSalmon", opacity=0.3,
    layer="below", line_width=0,
    legendgrouptitle_text="Saturation",
    legendgroup='saturation',
    name='partial',
    showlegend=True,
)

fig.add_vrect(
    x0=3.5, x1=4.5,
    fillcolor="LightSalmon", opacity=0.3,
    layer="below", line_width=0,
    legendgroup='saturation',
    name='partial 2',
    showlegend=False,
)

fig.show()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions