Density plot

Welcome in the density plot section of the gallery. If you want to know more about this kind of chart, visit If you're looking for a simple way to implement it in R, pick an example below.

Using the ggplot2 library

A density plot shows the distribution of a numeric variable. In ggplot2, the geom_density() function takes care of the kernel density estimation and plot the results. A common task in dataviz is to compare the distribution of several groups. The graph #135 provides a few guidelines on how to do so.

Related chart types