【问题标题】:set relative titles per row for multiple chart plot为多个图表设置每行的相对标题
【发布时间】:2016-05-26 16:26:09
【问题描述】:

有没有什么方法可以为一个由 4 列 5 行 20 个图组成的图设置 5 个子标题?

附上图表的图片。

我尝试通过以下方式插入标题,但调整输出图会移动标题。

mtext("Frankfurt (Forecast 2012 - 2033)", side = 3, line = -1.5, outer = TRUE)

我找到了以下几行代码,但这些代码似乎只与 20 个图表中的一个有关,而不是整个情节

op <- par("usr") 
par(usr = c(0, 1, 0, 1)) 
text(0.5,0.5,"TEST") 
par(usr = op) 

http://i.imgur.com/j0AfMxE.png?1

【问题讨论】:

  • 您能否提供一个可重现示例的示例数据?

标签: r plot title


【解决方案1】:

这是我的方法。

mat <- matrix(c(rep(1,4), 6:9, rep(2,4), 10:13, rep(3,4), 14:17, rep(4,4), 18:21, 
                rep(5,4), 22:25), ncol=4, byrow=T)
mat                  # 1-5: subtitle, 6-: mainplot
layout(mat, heights=c(rep(c(1, 20), 5)))   # heights setting (rough)

par(mar=c(0,0,0,0))
for(i in 1:5) {
  plot(0, 0, type="n", ann=F, axes=F)  # plotting white paper & subtitle
  mtext(side=1, line=0.2, "subtitle")  # do it five times
}

par(mar=c(2, 2, 2.7, 1), mgp=c(3, 0.6, 0))  # margins and tick lab position set
for(i in 1:20) {
  plot(rnorm(30), ann=F)            # main plot
  title(LETTERS[i], line=0.3)       # each title (don't use plot(main=))
}

【讨论】:

    猜你喜欢
    • 2020-01-31
    • 2018-05-26
    • 2023-03-27
    • 2021-11-13
    • 2020-11-11
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多