将正态分布曲线添加到直方图R [英] Add normal distribution curve to histogram R
本文介绍了将正态分布曲线添加到直方图R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将正态分布曲线叠加到R中的直方图上.我知道这是一个曾经被问过的问题,但是我很难找到适合我的解决方案.
I'm trying to overlay a normal distribution curve onto a histogram in R. I know it's a question that's been asked before, but I'm having trouble getting the solutions to work for me.
这是我的代码:
hist(input_data$"X109_scalesraw_23", freq = TRUE, breaks = 30,
col = "cadetblue", xlim = c(0,30), ylim = c(0,150),
main = "023", xlab = "score")
推荐答案
您始终可以将curve
与add=TRUE
结合使用(告诉R将曲线添加到现有绘图中):
You can always use curve
with add=TRUE
(telling R to add the curve to existing plot):
data <- rnorm(100, 0, 1)
hist(data, freq = FALSE)
x<-seq(-4,+4,by=0.02)
curve(dnorm(x), add=TRUE)
产生
这篇关于将正态分布曲线添加到直方图R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文