Exercise

# Adjusting the number of bins in a histogram

The histogram you just made had ten bins. This is the default of matplotlib. The "square root rule" is a commonly-used rule of thumb for choosing number of bins: choose the number of bins to be the square root of the number of samples. Plot the histogram of *Iris versicolor* petal lengths again, this time using the square root rule for the number of bins. You specify the number of bins using the `bins`

keyword argument of `plt.hist()`

.

The plotting utilities are already imported and the seaborn defaults already set. The variable you defined in the last exercise, `versicolor_petal_length`

, is already in your namespace.

Instructions

**100 XP**

- Import
`numpy`

as`np`

. This gives access to the square root function,`np.sqrt()`

. - Determine how many data points you have using
`len()`

. - Compute the number of bins using the square root rule.
- Convert the number of bins to an integer using the built in
`int()`

function. - Generate the histogram and make sure to use the
`bins`

keyword argument. - Hit 'Submit Answer' to plot the figure and see the fruit of your labors!