您可以将ggplot转换为grob,并在其中进行更改:
# convert to grob
gp <- ggplotGrob(p) # where p is the original ggplot object
# assign the first 4 right-side facet strips with blue fill
for(i in 1:4){
grob.i <- grep("strip-r", gp$layout$name)[i]
gp$grobs[[grob.i]]$grobs[[1]]$children[[1]]$gp$fill <- "blue"
}
# assign the next 4 right-side facet strips with red fill
for(i in 5:8){
grob.i <- grep("strip-r", gp$layout$name)[i]
gp$grobs[[grob.i]]$grobs[[1]]$children[[1]]$gp$fill <- "red"
}
grid::grid.draw(gp)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句