Last active
February 17, 2020 20:02
-
-
Save baptiste/eadeecd7d3756a7f294eb3cade8b0b17 to your computer and use it in GitHub Desktop.
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
library(egg) | |
library(gridExtra) | |
library(ggplot2) | |
library(grid) | |
d <- data.frame(x=runif(10*7), | |
y=runif(10*7), | |
f1 = gl(7,10), | |
f2 = gl(3, 30, 7*10)) | |
p <- ggplot(d, aes(x,y))+ | |
facet_grid(f2~f1)+ | |
geom_line() | |
ld <- split(d, d$f2) | |
lp <- lapply(ld, `%+%`, e1 = p) | |
ggarrange(plots=lp) | |
lg <- lapply(lp, egg::set_panel_size, | |
width=unit(4,'cm'), height=unit(1,'null')) | |
rows <- lapply(lg, function(x) | |
arrangeGrob(rectGrob(gp=gpar(col=NA)), x, nrow=1, | |
widths = unit.c(unit(1,'null'), sum(x$widths)))) | |
grid.newpage() | |
grid.arrange(grobs = rows, ncol=1) | |
Author
baptiste
commented
Feb 17, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment