plotly / plotly/plotly.py

Set barmode="overlay" in histograms by default to avoid misunderstandings

Open
#4,893 2 comments 0 reactions 0 assignees View on GitHub

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 :
Image

While overlying clearly shows that it is just shifted

px.histogram(df, x="data", color="series", barmode="overlay")

Image

This leads to misunderstanding the data shape.

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.