Skip to content

Instantly share code, notes, and snippets.

@kozo2
Forked from kohske/spfw.R
Last active August 29, 2015 14:18
Show Gist options
  • Save kozo2/c5a856fb54fca578cb75 to your computer and use it in GitHub Desktop.
Save kozo2/c5a856fb54fca578cb75 to your computer and use it in GitHub Desktop.
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