2012-02-20 97 views
1

我想绘制几个概率分布的副路(密度在X轴上,变量在Y轴上)。每个发行版都将与不同的类别相关联,并且我希望它们并排排列,以便我可以在它们之间进行比较。这有点像盒子图,但我想要一个理论概率分布,我将指定给定参数。所以,如果它们都是正态分布,我会简单地提供每种分布的均值和标准偏差。谢谢。如何在R中并排绘制多个概率分布?

+0

这是一个家庭的分布或几个家庭的PDF文件?你有没有尝试过这个页面的代码? http://www.statmethods.net/advgraphs/probability.html – 2012-02-20 13:04:41

回答

2

你的意思是这样的吗?

x <- seq(-10, 10, length=100) 
normal.dist <- dnorm(x, 0, 2) 
f.dist <- df(x, 3, 4) 
t.dist <- dt(x, 3) 
chi.dist <- dchisq(x,3) 
par(mfrow=c(2,2)) 
plot(x, normal.dist, type='l', lty=1) 
plot(x, f.dist, type='l', lty=1, xlab="x value", col='blue') 
plot(x, t.dist, type='l', lty=1, xlab="x value", col='red') 
plot(x, chi.dist, type='l', lty=1, xlab="x value", col='green') 

也看到罗马Luštrik的非常有帮助的链接,以及在helfiles(例如?dnorm)。

enter image description here

旋转的轴

x <- seq(-10, 10, length=100) 
normal.dist <- dnorm(x, 0, 1) 
normal.dist2 <- dnorm(x, 0, 2) 
normal.dist3 <- dnorm(x, 0, 3) 
normal.dist4 <- dnorm(x, 0, 4) 


par(mfrow=c(2,2)) 
plot(normal.dist, x, type='l', lty=1) 
plot(normal.dist2, x, type='l', lty=1, col='red') 
plot(normal.dist3, x, type='l', lty=1, col='green') 
plot(normal.dist4, x, type='l', lty=1, col='blue') 

enter image description here

+0

我想要类似的东西,但正常分布旋转。但感谢您的答案。 – Mark 2012-02-20 15:44:46

+0

很容易修复。只需交换前两个参数'plot(f.dist,x,type ='l',lty = 1,ylab =“x value”,col ='blue')'和relabel坐标轴。 – 2012-02-20 15:57:58

0

您可以设置为情节显示一帧,并指定你要多少情节用面值一帧显示(mfrow ()),例如:

par(mfrow=c(2,2)) 
plot(first plot) 
plot(second plot) 
hist(third histogram) 
boxplot(fourth boxplot) 

查看以下链接的完整描述: http://www.statmethods.net/advgraphs/layout.html