diamonds 是内置数据集
library
(ggplot2)
ggplot(diamonds, aes(carat)) +
geom_density()
ggplot(diamonds, aes(depth, colour = cut)) +
geom_density() +
xlim(55, 70)
更多示例: https://ggplot2.tidyverse.org/reference/geom_density.html#examples