Created
January 22, 2021 14:49
-
-
Save h-a-graham/828ceeb7a51d5c0da298146edae4e667 to your computer and use it in GitHub Desktop.
Add colours to right hand facets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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