legend_tracegroupgap doesn't work when legend_traceorder is used
Open
Nobody has claimed this yet.
bug
P3
sev-4
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Note: to reproduce, see here
The problem
Baseline
long_df = px.data.medals_long()
fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form")
fig.update_layout(width=680, height=480,)
fig.show()
works just fine:

Increasing the gap works
long_df = px.data.medals_long()
fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form")
fig.update_layout(autosize=False, width=680, height=480, legend_tracegroupgap=50)
fig.show()
also works fine

Increasing the gap & reversing doesn't work
long_df = px.data.medals_long()
fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form Input")
fig.update_layout(width=680,height=480, legend_traceorder="reversed", legend_tracegroupgap=50)
fig.show()
gives

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Colab reproduction and compare legend_traceorder="reversed" with legend_tracegroupgap=50 in the Plotly Python entry points. Trace how these two layout properties are handled together. Done means the configured gap remains visible when the legend trace order is reversed.
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
- 38/100