首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在R中并排绘制多个概率分布?

如何在R中并排绘制多个概率分布?
EN

Stack Overflow用户
提问于 2012-02-20 20:39:42
回答 2查看 983关注 0票数 1

我想横向绘制几个概率分布(x轴上的密度,y轴上的变量)。每个发行版都将与一个不同的类别相关联,我希望将它们并排放在一起,以便我可以在它们之间进行比较。这有点像盒子图,但我想要一个理论上的概率分布,我将指定给定的参数。因此,如果它们都是正态分布,我会简单地提供每个的平均值和标准差。谢谢。

EN

回答 2

Stack Overflow用户

发布于 2012-02-20 21:16:37

你是说像这样的东西吗?

代码语言:javascript
复制
 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')

另请参阅Roman Lu的helfiles (例如?dnorm)的štrik的非常有用的链接。

旋转轴

代码语言:javascript
复制
 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' )

票数 2
EN

Stack Overflow用户

发布于 2012-02-20 23:51:16

您可以设置一个用于绘图显示的框架,并使用par(mfrow())指定要在一个框架中显示多少绘图,例如:

代码语言:javascript
复制
par(mfrow=c(2,2))
plot(first plot)
plot(second plot)
hist(third histogram)
boxplot(fourth boxplot)

有关完整说明,请参阅以下链接:http://www.statmethods.net/advgraphs/layout.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9361260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档