Histograms

Histograms#

A histogram is a type of plot that approximates the distribution of numerical data.

  • The first step in constructing a histogram is to bin or bucket the range of values. In other words, we need to divide the entire range of values into a series of intervals.

  • The second step in constructing a histogram is to count how many values fall into each interval.

In a histogram, the bins are usually consecutive, non-overlapping intervals. The bins must be adjacent and are often (but not necessarily) of equal size.

%matplotlib inline
import matplotlib.pyplot as plt, numpy as np # import statements

data = np.random.randn(1000) # create randomized dataset
fig, ax = plt.subplots() # create figure
ax.hist(data) # create histogram with default bins
plt.show() # show output

Additional Resources#

For more on histograms: