c <- circleGrob(r=.25, gp=gpar(col=NA, fill="white")) r <- rectGrob(x=c(1, 1, 3, 3)/4, y=c(1, 3, 3, 1)/4, width=.3, height=.3, gp=gpar(col=NA, fill="grey")) p <- pattern(gTree(children=gList(r, c)), x=.5, y=.5, width=unit(2, "cm"), height=unit(2, "cm")) grid.rect(name="r3") grid.patternFill("r3", p) library(ggplot2) cxc <- ggplot(mtcars, aes(x = factor(cyl))) + geom_bar(width = 1, colour = "black") + coord_polar(theta = "y") gg <- ggplotGrob(cxc) p <- pattern(gg, x=.5, y=.5, width=unit(4, "cm"), height=unit(4, "cm")) grid.rect(name="r4") grid.patternFill("r4", p) pdf(NULL, width=12, height=3) # grid.newpage() pushViewport(viewport(x=1/4, width=.4, height=.8)) c <- circleGrob(r=.25, gp=gpar(col=NA, fill="white")) r <- rectGrob(x=c(1, 1, 3, 3)/4, y=c(1, 3, 3, 1)/4, width=.3, height=.3, gp=gpar(col=NA, fill="grey")) p <- pattern(gTree(children=gList(r, c)), x=.5, y=.5, width=unit(2, "cm"), height=unit(2, "cm")) grid.rect(name="r3") grid.patternFill("r3", p) popViewport() pushViewport(viewport(x=3/4, width=.4, height=.8)) library(ggplot2) cxc <- ggplot(mtcars, aes(x = factor(cyl))) + geom_bar(width = 1, colour = "black") + coord_polar(theta = "y") gg <- ggplotGrob(cxc) p <- pattern(gg, x=.5, y=.5, width=unit(4, "cm"), height=unit(4, "cm")) grid.rect(name="r4") grid.patternFill("r4", p) popViewport() grid.export("Figures/export-patternfill2.svg") dev.off() system("chromium-browser --headless --screenshot=Figures/export-patternfill2.png --window-size=880x220 Figures/export-patternfill2.svg") system("cp Figures/export-patternfill2.png Web/export-patternfill2.png")