An histogram is an accurate graphical representation of the distribution of numeric data. It takes as input one numerical variable only. The variable is cut into several **bins**, and the

number of observation per bin is represented by the **height** of the bar. Note that the shape of the histogram can be really different following the number of bins you set. Thus, try different

values before taking any conclusion. Note that it is really close to density plot. To compare several distributions, add them on the same axis or use violinplots.

Sponsors

**Ggplot2
**

The ggplot2 library offers a specific function to draw histograms: **geom_histogram**. Here are a few examples:

**Base R
**

Of course the base version of R can handle very well the creation of histograms as well:

**Interactive version**

Contrary to other chart type (like scatterplot), interactivity does not improve much your histogram. Still, here are a few examples of interactive histograms using the plotly library. If you have a low number of observation, you can consider doing an interactive dotplot histogram as proposed below.

#337: interactive dotplot histogram

**Other chart involving histogram
**

**Related**

Looking for something else ? Try a search !

## Leave a Reply