# Histogram Bin Size with Plotly Express

**URL:** <https://community.plotly.com/t/histogram-bin-size-with-plotly-express/38927>\
**Category:** 📊 Plotly Python\
**Created:** [May 5, 2020, 12:36pm UTC](https://community.plotly.com/t/histogram-bin-size-with-plotly-express/38927 "2020-05-05T12:36:27Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![joseph.damiba](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@joseph.damiba](https://community.plotly.com/u/joseph.damiba)\
**Post date:** [May 5, 2020, 2:19pm UTC](https://community.plotly.com/t/histogram-bin-size-with-plotly-express/38927/5 "2020-05-05T14:19:40Z")

</div>

Thanks for taking the time to further explain your use case.

You are right that you cannot pass an `xbins` attribute directly to the `px.histogram` constructor.

This is because Plotly Express was designed as a terse, high-level wrapper for the `graph_objects` library, so only a subset of the attributes that you can set using a `graph_objects` constructor are available in the Plotly Express constructors for figures.

However, it is important to note that the Plotly Express constructor always returns a `graph_objects` figure object.

This means you can use the `update_traces` method to set any attributes which are available on the figure after using the Plotly Express constructor.

```python
import plotly.express as px
df = px.data.tips()
fig = px.histogram(df, x="total_bill")

fig.update_traces(xbins=dict( # bins used for histogram
        start=0.0,
        end=60.0,
        size=2
    ))

fig.show()

```

 ![Screen Shot 2020-05-05 at 10.17.44 AM](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/6fafad8a7030bd710daa5be4b0ccd8bae4c05e77.png)

I hope that answers your question.

---

_[View the full topic](https://community.plotly.com/t/histogram-bin-size-with-plotly-express/38927)._
