[R] ggplot2 and mtext question

Ben Bolker bolker at ufl.edu
Sun Aug 23 18:04:28 CEST 2009

Data Analytics Corp. wrote:
> Hi,
> In R base graphics, the function mtext can be used to add text to the 
> margins of a plot.  This is very useful for adding notes (such as data 
> source, sample size, etc.) to the bottom of a graph.  How can such notes 
> be added to the bottom of a graph when using ggplot2?

Can't think of an easy/elegant way.
One quick hack:

> d = data.frame(x=1:10,y=runif(10))
> ggplot(d,aes(x=x,y=y))+geom_point()+labs(x="abc\n\nnote:def")

 you might also have some luck with grid.text:


View this message in context: http://www.nabble.com/ggplot2-and-mtext-question-tp25103495p25104611.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list