plotly / plotly/plotly.py

Bug: express bar chart with facet_col and color. It show wrong chart when clicking legend

Open
#5,387 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Example:

import pandas as pd
import plotly.express as px
data = {
'Category': ['A', 'B', 'A', 'A', 'B', 'A'],
'Date': ['2025-10-11', '2025-10-11', '2025-10-12', '2025-10-13', '2025-10-13', '2025-10-13'],
'Value': [10, 15, 12, 8, 20, 5],
'Group': ['X', 'X', 'Y', 'Y', 'X', 'Y']
}
df = pd.DataFrame(data)
fig = px.bar(df, x='Date', y='Value',color='Category', facet_col="Group")
fig.show()
Image
When click legend Category B to keep Category A only. It's gone for Group=X

Image

Workaround
for trace in fig.data:
trace.width=8200000

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 provided pandas and plotly.express px.bar example with facet_col="Group" and color="Category". Reproduce the legend interaction that removes Category A from Group=X, then trace the bar-chart and legend handling involved. Done means clicking a legend item preserves the expected bars in every facet without requiring the width workaround.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.