Skip to main contentSkip to solution

What does the bins parameter in plt.hist() control?

Solution

✅ Correct Option: 3

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question