plotly / plotly/plotly.py

updatemenu button moves on 2nd click

Open
#3,575 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

https://user-images.githubusercontent.com/30958850/151654960-7786bdbb-3949-44a2-922a-a9e4cb045629.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()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal Python example and reproducing the second-click movement of the updatemenu button while toggling the legend. Trace the legend and updatemenu layout handling, then verify that repeated toggles leave the button position unchanged under the reported conditions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.