# Set custom bin sizes in histogram

**URL:** <https://community.plotly.com/t/set-custom-bin-sizes-in-histogram/46645>\
**Category:** 📊 Plotly Python\
**Created:** [October 29, 2020, 2:40pm UTC](https://community.plotly.com/t/set-custom-bin-sizes-in-histogram/46645 "2020-10-29T14:40:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaz](https://avatars.discourse-cdn.com/v4/letter/z/bbce88/32.png) [@zaz](https://community.plotly.com/u/zaz)\
**Post date:** [October 29, 2020, 2:40pm UTC](https://community.plotly.com/t/set-custom-bin-sizes-in-histogram/46645/1 "2020-10-29T14:40:18Z")

</div>

I have some data from a dataframe column that I am trying to put into a histogram in custom bin sizes, that are static - not dynamically generated based on the data.

The data are minutes. Here is an example (with index):

0 6.966667  
1 29.716667  
2 24.516667  
3 29.833333  
6 21.533333  
7 11.916667  
8 18.816667  
9 23.533333  
10 21.466667  
11 11.550000  
12 17.200000  
13 27.216667  
14 21.533333

The bin sizes will always be: (0-15], (15-30], (30-45], (45-60], (60-75], 75+

I am having trouble finding how I can set up my histogram bins to categorize the data this way. I have read through all the documentation I can find, and the help pages and not quite finding what I need.

This is some of my code, but it still creates only 2 bins:

```auto
import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=2)
trace0 = go.Histogram(x=df[col_name], xbins=dict(
                                      start=0,
                                      end=75,
                                      size=15), 
                                      autobinx=False)
trace1 = go.Histogram(x=df[col_name], nbinsx=6)
fig.append_trace(trace0, 1, 1)
fig.append_trace(trace1, 1, 2)

fig.show()

```

I was looking at possibly setting up a frequency table and then using a bar chart off of that, but I like the overlay feature of the histograms so would like to stay in that part of the library if possible.

Thank you!
