问题 I want to add a density line (a normal density actually) to a histogram. Suppose I have the following data. I can plot the histogram by ggplot2 : set.seed(123) df <- data.frame(x = rbeta(10000, shape1 = 2, shape2 = 4)) ggplot(df, aes(x = x)) + geom_histogram(colour = "black", fill = "white", binwidth = 0.01) I can add a density line using: ggplot(df, aes(x = x)) + geom_histogram(aes(y = ..density..),colour = "black", fill = "white", binwidth = 0.01) + stat_function(fun = dnorm, args = list