【R 语言 可视化】在直方图上面添加密度曲线

这里写图片描述

rm(list=ls())
gc()
set.seed(1234)
score <- rnorm(n = 1000, m = 80, sd = 20)
hist(score, 
     freq=FALSE, 
     xlab="Score", 
     main="Distribution of score", 
     col="lightgreen", 
     xlim=c(0,150), 
     ylim=c(0, 0.02))
curve(dnorm(x, 
            mean=mean(score), 
            sd=sd(score)), 
      add=TRUE, 
      col="darkblue", 
      lwd=2)

猜你喜欢

转载自blog.csdn.net/It_BeeCoder/article/details/83090689