How to place grobs with annotation_custom() at precise areas of the plot region?

Here’s how I would approach this, library(gtable) library(ggplot2) library(plyr) set.seed(1) d <- data.frame(x=rep(1:10, 5), y=rnorm(50), g = gl(5,10)) # example plot p <- ggplot(d, aes(x,y,colour=g)) + geom_line() + scale_x_continuous(expand=c(0,0))+ theme(legend.position=”top”, plot.margin=unit(c(1,0,0,0),”line”)) # dummy data for the legend plot # built with the same y axis (same limits, same expand factor) d2 <- ddply(d, “g”, summarise, … Read more