How to add a border around a chart created via arrange.grid in gridExtra encompassing a set ggplot2 scatter plots

前端 未结 2 655
抹茶落季
抹茶落季 2020-12-14 21:17

I\'m using the code below:

# Libs
require(ggplot2); require(gridExtra); require(grid)

# Generate separate charts
chrts_list_scts <- list()

# Data
data(\         


        
2条回答
  •  独厮守ぢ
    2020-12-14 21:39

    you can add a rectGrob to the gtable

    grid.draw(gtable::gtable_add_grob(arrangeGrob(g, g, ncol=2),
                 rectGrob(gp=gpar(lwd=5, fill=NA)), 1, 1, 1, 2))
    

    NOTE: fill=NA or fill='transparent' is required otherwise the rectangle can mask the objects below it.

提交回复
热议问题