Skip to content

Normalized Histogram with Marginal producing the wrong plot #4426

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

Open
murk3000 opened this issue Nov 16, 2023 · 2 comments
Open

Normalized Histogram with Marginal producing the wrong plot #4426

murk3000 opened this issue Nov 16, 2023 · 2 comments
Labels
bug something broken P3 backlog sev-4 cosmetic

Comments

@murk3000
Copy link

Using plotly.express (px) to plot a Histogram with barnorm = 'percent' and marginal = 'histogram' produces a plot where the barnorm is ignored and the raw counts are plotted. I think the output should be a histogram with barnorm = 'percent' and a marginal histogram with the regular counts.

px.histogram(pd.DataFrame({'x': np.random.normal(0, 1, 100),
                           'col': np.random.choice(['A', 'B'], 100)}), 
             x='x', color='col', barnorm='percent', marginal='histogram')
@archmoj
Copy link
Contributor

archmoj commented Nov 21, 2023

It's working if you use the following code:

import plotly.express as px
import pandas as pd
import numpy as np

df = pd.DataFrame({
    'x': np.random.normal(0, 1, 100),                           
    'col': np.random.choice(['A', 'B'], 100)
})

fig = px.histogram(df,
    x='x', 
    color='col', 
    barnorm='percent', 
    marginal='rug'
)

fig.show()

@murk3000
Copy link
Author

The rug marginal is different than the histogram marginal in this case. My issue is when the same marginal as the plot (histogram in my code example) is used, the barnorm parameter is ignored.

@Coding-with-Adam Coding-with-Adam added bug something broken sev-4 cosmetic labels Nov 22, 2023
@gvwilson gvwilson self-assigned this Jul 11, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog sev-4 cosmetic
Projects
None yet
Development

No branches or pull requests

4 participants