What does the bins parameter in plt.hist() control?
What does the bins parameter in plt.hist() control?
Solution
The bins parameter in plt.hist() sets how many equal-width intervals the data range is divided into. Each interval becomes one bar, and its height shows how many values fall in that interval. For example, bins=10 splits the data into 10 intervals.
Option 1: bin width changes as a side effect of the number of bins, but it is not what the parameter directly sets.
Option 2: the range of values is set by the range parameter, not bins.
Option 4: bar spacing is not controlled by bins; bars in a histogram touch unless the rwidth parameter is used.
Related questions:
2025: 3 June Shift 2
2025: 30 May Shift 2
2025: 27 May Shift 2
2025: 13 May Shift 2
2025: 14 May Shift 1
2025: 22 May Shift 1