Add shaded standard error curves to geom_density in ggplot2
问题 I would like to add shaded standard error curves to geom_density using ggplot2 . My code looks like this: data.plot <- data.frame(x = c(rnorm(100, mean = 0, sd = 5), rnorm(100, mean = 1, sd =2 )), g = factor(c(rep(1, 100), rep(2,100)))) ggplot(data.plot, aes(x, linetype = g)) + geom_density() I couldn't find a tutorial or examples to do so. Thank you. 回答1: The best solution is with bootstrapping, as mentioned in the comments. I'll use the classic iris data, focusing on the density of Sepal