Skip to content

updatemenu button moves on 2nd click #3575

Open
@janosh

Description

@janosh

Adding an updatemenu button to toggle the legend, the button shifts to the left on 2nd click under certain conditions.

Screen.Recording.2022-01-29.at.08.45.02.mp4

Minimal Example

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")

legend = dict(
    x=1, y=1, xanchor="right", yanchor="top", groupclick="toggleitem"
)

legend_toggle = dict(
    args=["showlegend", True],
    args2=["showlegend", False],
    label="Toggle legend",
    method="relayout",
)

fig.update_layout(
    legend=legend,
    updatemenus=[
        dict(type="buttons", buttons=[legend_toggle], showactive=True, x=1, y=1)
    ],
)

fig.update_xaxes(range=[0, 10])

fig.show()

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