Skip to content

px.histogram draws incorrect size of count bars when grouped by color #2538

@ghost

Description

Screenshot 2020-06-05 at 11 28 29

Hi,

I believe I have found an issue with plotly express which is visible even on the tutorial page. Namely when drawing a histogram with plotly express and using color argument to group data, the size of count bars is bigger than the real count value.

Code from tutorials can be used as a reproducible example (section: Visualizing the distribution):
https://plotly.com/python/histograms/ Count bars for Male group are bigger than actual counts displayed when we hover over the bar. E. g. for total_bill = 16 - 17.99 we have count = 18 in the annotation, but the value displayed is greater than 30. I've manually checked a few values for various plots and the true value is correctly displayed in the annotation. The count bars are however much bigger than they should.

For completeness, here's the code which is being used in the tutorial:

import plotly.express as px
df = px.data.tips()
fig = px.histogram(df, x="total_bill", color="sex", marginal="rug", # can be `box`, `violin`
                         hover_data=df.columns)
fig.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions