2012-02-20 79 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