Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Wrong Histogram chart with integer numbers #136

Open
dmib opened this issue Aug 19, 2019 · 2 comments
Open

Wrong Histogram chart with integer numbers #136

dmib opened this issue Aug 19, 2019 · 2 comments

Comments

@dmib
Copy link

dmib commented Aug 19, 2019

Step to reproduce:

import plotly.express as px
tips = px.data.tips()
tips = tips[tips["size"].isin([1,4,6])]
fig = px.histogram(tips, x="size", y="tip", histfunc='count')
fig.show()

output:

image
expect result:

image

Thanks.

@nazariyb
Copy link

By default it used 4 bins and merge data from neighboring columns into one. Specify number of bins:
fig = px.histogram(tips, x="size", y="tip", histfunc='count', nbins=len(tips))

@nicolaskruchten
Copy link
Contributor

@nazariyb's answer is pretty much what I would write. The bins in your first figure are correct, they just span multiple sizes, and you can control this behaviour with nbins

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants