This blog is part of Matplotlib Series:

- Matplotlib Series 1: Bar chart
- Matplotlib Series 2: Line chart
- Matplotlib Series 3: Pie chart
- Matplotlib Series 4: Scatter plot
- Matplotlib Series 5: Treemap
- Matplotlib Series 6: Venn diagram
- Matplotlib Series 7: Area chart
- Matplotlib Series 8: Radar chart
- Matplotlib Series 9: Word cloud
- Matplotlib Series 10: Lollipop plot
- Matplotlib Series 11: Histogram (this blog)

## Histogram

A histogram is an accurate representation of the distribution of numerical data. It differs from a bar graph, in the sense that a bar graph relates two variables, but a histogram relates only one. To construct a histogram, the first step is to “bin” (or “bucket”) the range of values-that is, divide the entire range of values into a series of intervals—and then count how many values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. The bins (intervals) must be adjacent, and are often (but are not required to be) of equal size.

### When to use it ?

- Estimating the probability distribution of a continuous variable (quantitative variable).
- Organizing large amounts of data, and producing a visualization quickly, using a single dimension.

### Dataframe

### Basic histogram

This plot describes that among 1930 tickets, 11% tickets contain less than 5 products; less than 1% tickets contain less than 21 products but more than 16 products. However, if we want to the percentage of tickets that contains less than or egale to 10 products, this basic histogram cannot satisfy our need in one second. In the following cumulative histogram, we can find the answer.

### Cumulative histogram

Considering the same question as above: what the percentage of tickets that contain less than or egale to 10 products? According to this cumulative histogram, the answer is obvious: nearly 85% tickets contain less than or egale to 10 products.

You can click here to check this example in jupyter notebook.

## Reference

- Steve Johnson, “painting wallpaper”,
*www.pexels.com*. [Online]. Available: https://www.pexels.com/photo/painting-wallpaper-1070527/