R 中的多面板标题

发布于 2024-08-18 16:39:56 字数 214 浏览 3 评论 0原文

我有一个关于 R 的超简短问题,

我的目标是为使用 par 生成的多面板图分配一个通用标题,例如

par(mfrow=c(1,2))
plot(rnorm(1000))
plot(rnorm(1000))

,所以,类似于绘图函数的“main”,但扩展到两个图。有规范的方法可以做到这一点吗?

感谢您的任何答复:-)

I have an ultra short question about R

My aim is to assign a common title to a multi-panel plot generated using par, e.g.

par(mfrow=c(1,2))
plot(rnorm(1000))
plot(rnorm(1000))

So, something like "main" for the plot function, but extended to both plots. Is there a canonical way to do this?

Thanks for any answer :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笔一画续写前缘 2024-08-25 16:39:56

mtext 与选项 outer 结合使用:

set.seed(42)
oldpar <- par(mfrow=c(1,2), mar=c(3,3,1,1), oma=c(0,0,3,1))  ## oma creates space 
plot(cumsum(rnorm(100)), type='l', main="Plot A")
plot(cumsum(rnorm(100)), type='l', main="Plot B")
mtext("Now isn't this random", side=3, line=1, outer=TRUE, cex=2, font=2)
par(oldpar)

Use mtext with option outer:

set.seed(42)
oldpar <- par(mfrow=c(1,2), mar=c(3,3,1,1), oma=c(0,0,3,1))  ## oma creates space 
plot(cumsum(rnorm(100)), type='l', main="Plot A")
plot(cumsum(rnorm(100)), type='l', main="Plot B")
mtext("Now isn't this random", side=3, line=1, outer=TRUE, cex=2, font=2)
par(oldpar)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文