Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is nbins in Plotly

Tags:

python

plotly

I couldn't find this in the documents. The plotly Graphing Libraries have the below example but didn't seem to explain its arguments.

import plotly.express as px
df = px.data.tips()
fig = px.histogram(df, x="total_bill", nbins=20)
fig.show()

produced the plot below: enter image description here

From the plot, it doesn't look like the number of bins. Neither does it reflect the bin value interval nor counts in each bin. What does nbins=20 mean?

like image 251
nilsinelabore Avatar asked Sep 07 '25 04:09

nilsinelabore


1 Answers

That is the maximum not the fixed number of bins that you can set. From elsewhere in the documentation:

"This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data"

like image 158
Raspberry PyCharm Avatar answered Sep 10 '25 07:09

Raspberry PyCharm