1import plotly.express as px
2df = px.data.tips()
3fig = px.histogram(df, x="total_bill", nbins=20)
4fig.show()
5
1import plotly.express as px
2import numpy as np
3
4df = px.data.tips()
5# create the bins
6counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5))
7bins = 0.5 * (bins[:-1] + bins[1:])
8
9fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'})
10fig.show()
11