标签:uil plot child table rect change fill children spl
### change ggplot strip colours
p <- ggplot(mpg, aes(displ, cty)) + geom_point() + facet_grid(drv ~ cyl)
p
g <- ggplot_gtable(ggplot_build(p))
strip_both <- which(grepl(‘strip-‘, g$layout$name))
fills <- c("red","green","blue","yellow","red","green","blue","yellow")
k <- 1
for (i in strip_both) {
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.draw(g)
标签:uil plot child table rect change fill children spl
原文地址:https://www.cnblogs.com/huangying78/p/9937988.html