R语言ggplot2::geom_density绘制概率密度图

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

posted @ 2021-06-09 18:12  船长博客  阅读(3622)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!