如何在R中绘制两个标准差的正态分布图

如何在R中绘制两个标准差的正态分布图

问题描述:

我是R中的新手,想绘制一个正态分布图,其中两个标准偏差的区域由箭头选择,如下所示。如何在R中绘制两个标准差的正态分布图

enter image description here

这个问题缺乏努力,但它激起了我的兴趣,所以你有它:

#standard normal distribution data 
x <- seq(-4, 4, length=100) 
hx <- dnorm(x) 

#plot a standard normal distribution 
plot(x, hx, type="l", lty=2, xlab="x value") 
#plot a vertical line at -2*std 
abline(v=-2, col='red') 
#plot a vertical line at 2*std 
abline(v= 2, col='red') 
#make the arrow 
arrows(x0=-2, y0=0.35, x1=2, y1=0.35, code=3, col='blue') 
#plot the text 
text(x=0, y=0.37,labels='0.95%', col='red') 

结果:

enter image description here

+0

这个伟大的工程非常感谢你 – Homayoon