How to annotate across or between plots in multi-plot panels in R

前端 未结 4 575
耶瑟儿~
耶瑟儿~ 2020-12-18 00:33

If I have several plots in a single panel, I would like to be able to put text annotations that go across more than one plot area or that go in between plot areas. I\'m sure

4条回答
  •  自闭症患者
    2020-12-18 01:30

    If you truly want finer control over these kinds of layout issues, you can use the aptly named layout.

    m <- matrix(c(1,2,3,3,4,5,6,6),ncol = 2,byrow = TRUE)
    layout(m,widths = c(0.5,0.5),heights = c(0.45,0.05,0.45,0.05))
    
    par(mar = c(2,4,4,2) + 0.1)
    hist(x1, xlab="", main="Group A")
    hist(x2, xlab="", main="Group B")
    
    par(mar = c(0,0,0,0)) 
    plot(1,1,type = "n",frame.plot = FALSE,axes = FALSE)
    u <- par("usr")
    text(1,u[4],labels = "Here",col = "red",pos = 1)
    
    par(mar = c(2,4,2,2) + 0.1)
    hist(x3, xlab="", main="")
    hist(x4, xlab="", main="")
    
    par(mar = c(0,0,0,0)) 
    plot(1,1,type = "n",frame.plot = FALSE,axes = FALSE)
    u <- par("usr")
    text(1,u[4],labels = "Here",col = "red",pos = 1)
    

    enter image description here

提交回复
热议问题