# Dummy plot
base <- qplot(1:10, 1:10, geom = "blank") + theme_bw()
# Adding a table
if (require(gridExtra)) {
base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
xmin = 3, xmax = 6, ymin = 2, ymax = 8)
# full panel
base + annotation_custom(grob = roundrectGrob(),
xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
}
# Inset plot
g <- ggplotGrob(qplot(1, 1) +
theme(plot.background = element_rect(colour = "black")))
base +
annotation_custom(grob = g, xmin = 1, xmax = 10, ymin = 8, ymax = 10)
Run the code above in your browser using DataLab