Created
April 2, 2015 12:15
-
-
Save kohske/9abf67bd26f69ed851fd to your computer and use it in GitHub Desktop.
separate plot of facet_wrap in ggplot2
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(gtable) | |
d=data.frame(g=c(1,1,1,2,2,3),x=c(1,2,3,1,2,3),y=1:6); | |
p = ggplot(d,aes(x,y))+geom_bar(stat="identity")+facet_wrap(~g) | |
gt= ggplot_gtable(ggplot_build(g)) | |
graphics.off() | |
for (p in c(4, 7, 10)) { | |
pdf(paste0("plot-", p, ".pdf")) | |
grid.draw(gt[,c(1:3, p, 12)]) | |
dev.off() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍