Mirror density chart with ggplot2



A density plot is a representation of the distribution of a numeric variable. Comparing the distribution of 2 variables is a common challenge that can be tackled with the mirror density chart: 2 density charts are put face to face what allows to efficiently compare them. Here is how to build it with ggplot2 library.

Density Section Density theory

Density with geom_density


Histogram with geom_histogram


Related chart types


Violin
Density
Histogram
Boxplot
Ridgeline