[R] Putting names on a ggplot

ml at z107.de ml at z107.de
Sat Oct 17 23:53:56 CEST 2009


hi,

On Sat, Oct 17, 2009 at 02:04:43PM -0700, John Kane wrote:
> Putting names on a ggplot
> 
> p <- p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label =
> mlabs),
>       data = year, size = 2.5, colour='black', hjust = 0, vjust = 0)
> 

you shouldn't use aes in this case since nampost, temprange, ... are not
part of the dataframe year.

It should also work with geom_text i guess, but I prefere annotate for
thinks like that:

p + annotate("text",x=namposts+2.5, y = temprange[2], label=
    mlabs,size=2.5,colour='black', hjust = 0, vjust = 0)

regards,
    stefan



More information about the R-help mailing list