因为histogram和density的scale完全不一样, 把geom_histogram里面的y axis改成density 而不是frequency就可以了, code如下:
library(ggplot2)
mns=NULL
for(i in 1:10000) mns=c(mns,mean(rexp(40,0.2)))
ggplot(data.frame(mns),aes(x=mns))+geom_histogram(fill="lightblue",binwidth=0.5,col="black", aes(y = ..density..))+geom_line(stat="density",col="black",size=2)