# Univariate densities
kde <- dist_kde(c(rnorm(500), rnorm(500, 4, .5)))
gg_density(kde,
hdr = "fill", prob = c(0.5, 0.95), color = "#c14b14",
show_mode = TRUE, show_points = TRUE, jitter = TRUE
)
c(dist_normal(), kde) |>
gg_density(hdr = "fill", prob = c(0.5, 0.95))
# Bivariate density
tibble(y1 = rnorm(5000), y2 = y1 + rnorm(5000)) |>
dist_kde() |>
gg_density(show_points = TRUE, alpha = 0.1, hdr = "fill")
Run the code above in your browser using DataLab