A Ridgelineplot (formerly called Joyplot) allows to study the distribution of a numerical variable for several groups. In this example, we check the distribution of the price of diamonds following their quality.
This graph is made using the ggridges library, which is a ggplot2 extension and thus respect the syntax of the grammar of graphic. We specify the ‘price’ column for the X axis and the ‘cut’ column for the Y axis. Adding fill=cut allows to use one colour per category and display them as separate groups.
Check the Ridgeline section to learn how to custom this kind of graphic.
# basic example
ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
theme(legend.position = "none")
Search the gallery