Skip to content

Instantly share code, notes, and snippets.

@h-a-graham
Created January 22, 2021 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-a-graham/828ceeb7a51d5c0da298146edae4e667 to your computer and use it in GitHub Desktop.
Save h-a-graham/828ceeb7a51d5c0da298146edae4e667 to your computer and use it in GitHub Desktop.
Add colours to right hand facets
# this adds colours to the right hand facets
colour_right_facets <- function(plot){
g <- ggplot_gtable(ggplot_build(plot))
stripr <- which(grepl('strip-r', g$layout$name))
fills <- c("grey90","grey70","grey50")
k <- 1
for (i in stripr) {
j <- which(grepl('rect', g$grobs[[i]]$grobs[[1]]$childrenOrder))
g$grobs[[i]]$grobs[[1]]$children[[j]]$gp$fill <- fills[k]
k <- k+1
}
grid.arrange(g)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment