[R] ggplot() and annotation_custom()

Marc Girondot marc_grt at yahoo.fr
Sat Oct 15 15:29:46 CEST 2016

Until now I was using plot() and I check the possibility to shift to 

All is OK until now except to write text out of the plotting region 
[equivalent of par(xpd=TRUE); text(x, y, labels)].

I have found using google recommendation to use annotation_custom() but 
I still failed to print text out of the plotting region:


df <- data.frame(x = 1:10, y = 1:10)
ggplot(data=df, mapping=aes(x, y))+
   geom_line(color="black") +
   grob = textGrob(label="essai"), xmin=2.5, xmax=5, ymin=10, ymax=11
) + theme(plot.margin = unit(c(1.5, 1, 0.5, 0.5), "cm"))

If someone has the solution, I could continue to explore ggplot2 !

Thanks a lot,


More information about the R-help mailing list