ggplot and directlabels

i'm not a fan of legends in graphs. in my mind, lines that are labeled directly are easier to read. This is done easily with directlabels package by Toby Dylan Hocking.

Just create a ggplot object and wrap it in the command directlabels().

I used it, for example, to label a plot of abortion preferences overtime by liberal-conservative self-placement.

[sourcecode language="plain"]
abortion <- na.omit(ddply(.data=data, .variables=.(year,ideology), .fun=summarise, wtd.mean=mean(x=abortion,na.rm=T,weights=vcf0009a)))
direct.label(ggplot(abortion, aes(x = year, y = wtd.mean, colour=ideology)) + geom_line() + theme_bw() + opts(axis.title.x = theme_text(size = 12, vjust = .25)) + ylab("Support for Abortion Rights") + opts(legend.position="")+ scale_x_continuous(limits=c(1972,2015),breaks=seq(from=1972,to=2008,by=6))+xlab("Year"),"last.points")