简体   繁体   中英

What is nbins in 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: 在此处输入图片说明

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM