ggplot2 with logo

library(ggplot2)
library(grid)
library(gtable)
g <- ggplotGrob(qplot(1:3, 1:3))

logo below panel

g2 <- gtable_add_rows(g, heights = unit(1, "inch"))
g3 <- gtable_add_grob(g2, gglogo(theme=theme_gray()), nrow(g2), 1, nrow(g2), ncol(g2))
grid.draw(g3) # because plot.gtable draws background.

plot of chunk unnamed-chunk-2

logo on the right of panel

g2 <- gtable_add_cols(g, widths = unit(2, "inch"))
g3 <- gtable_add_grob(g2, gglogo(), 1, ncol(g2), nrow(g2), ncol(g2))
grid.draw(g3) # because plot.gtable draws background.

plot of chunk unnamed-chunk-3

logo inside panel

pos <- gtable_filter(g, "panel", trim=FALSE)$layout
g3 <- gtable_add_grob(g, gglogo(), pos$t, pos$l, pos$b, pos$r)
grid.draw(g3) # because plot.gtable draws background.

plot of chunk unnamed-chunk-4

scaled logo

pos <- gtable_filter(g, "panel", trim=FALSE)$layout
g3 <- gtable_add_grob(g, gglogo(scale=0.5), pos$t, pos$l, pos$b, pos$r)
grid.draw(g3) # because plot.gtable draws background.

plot of chunk unnamed-chunk-5