Set barmode="overlay" in histograms by default to avoid misunderstandings
Open
Nobody has claimed this yet.
feature
P3
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Reopening of #1865, as asked in the comment.
By default, histograms are not overlayed, which leads to misinterpretation :
import numpy as np
import pandas as pd
import plotly.express as px
x0 = np.random.randn(250)
# Add 1 to shift the mean of the Gaussian distribution
x1 = np.random.randn(250) + 1
df = pd.DataFrame(dict(
series=np.concatenate((["a"] * len(x0), ["b"] * len(x1))),
data=np.concatenate((x0, x1))
))
px.histogram(df, x="data", color="series")
Makes think that there is much more points in red distribution :
While overlying clearly shows that it is just shifted
px.histogram(df, x="data", color="series", barmode="overlay")
This leads to misunderstanding the data shape.
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 at the px.histogram entry point and trace how the barmode default is selected when color creates multiple series. Confirm the default changes to overlay, then verify the example behavior with the provided pandas and NumPy data and add or update relevant tests if the project has coverage for histogram defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100