Created
September 6, 2016 05:21
-
-
Save baptiste/a777bec843af1d95c9518efb672a9b68 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(gridExtra) | |
library(grid) | |
library(ggplot2) | |
xy <- polygon_regular(6)[-1,]*2 | |
pl <- replicate(6, ggplot() + coord_polar() + theme_grey(), simplify = FALSE) | |
gs <- do.call(gList, lapply(1:6, function(id) grobTree(ggplotGrob(pl[[id]]), vp=letters[id]))) | |
# gs <- do.call(gList, lapply(1:6, function(id) rectGrob(width=unit(2,"mm"), height=unit(2,"mm"), gp=gpar(fill=id), vp=letters[id]))) | |
midpage <- unit(0.5,"npc") | |
xl <- lapply(xy[,1], function(x) unit(x, "cm") + midpage) | |
yl <- lapply(xy[,2], function(x) unit(x, "cm") + midpage) | |
vps <- do.call(vpList, mapply(viewport, x=xl, y=yl, name = letters[1:6], | |
MoreArgs = list(width=unit(2,"cm"), height=unit(2,"cm")), | |
SIMPLIFY = FALSE)) | |
gl <- gTree(children = gs, | |
childrenvp = vps) | |
grid.newpage() | |
grid.draw(gl) |
Author
baptiste
commented
Sep 6, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment