ggplot2::geom_density()
带有刻面的默认设置和ggridges::geom_density_ridges()
产生的曲线略有不同。如何修改其中一种或另一种平滑技术以产生相同的结果?
library(tidyverse)
library(ggridges)
# standard density with facet by cyl ----
mtcars %>%
ggplot(aes(x = mpg)) +
geom_density(fill = "gray") +
facet_wrap(. ~ factor(cyl, levels = c(8, 6, 4)), ncol = 1) +
theme_minimal()
# density ridge with y = cyl ----
mtcars %>%
ggplot(aes(x = mpg, y = factor(cyl))) +
geom_density_ridges() +
theme_minimal()
#> Picking joint bandwidth of 1.38
由reprex 包(v0.2.1)于 2019 年 4 月 4 日创建