Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pierre-eliep-met opened this issue Nov 20, 2024 · 2 comments
Labels
feature something new P3 backlog

Comments

@pierre-eliep-met
Copy link

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.

@gvwilson gvwilson added bug something broken P3 backlog labels Nov 26, 2024
@gvwilson
Copy link
Contributor

@archmoj is this a plotly.py issue or should I move it to plotly.js?

@alexcjohnson
Copy link
Collaborator

I wouldn't call this a bug; often you explicitly want these histograms to stack so you can see the shape of the combined distribution. But perhaps this is the more common desire when you've split the distribution by color? Also I find the argument about consistency with marginals to be compelling.

@gvwilson I don't think this should be a change at the level of plotly.js, just px, so it can stay here. I'd also consider it a breaking change so if we were to do it we should do it in a major.

@gvwilson gvwilson added feature something new and removed bug something broken labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants